폼에서 입력을 받아서 PHP 배열에 저장하고 배열을 인쇄하고 싶습니다. 두 개의 파일, 즉 array.php와 marks.php가 있습니다. 정적 인 것으로 생각합니다. 도와주세요!이 PHP 코드의 출력을 얻으려면
marks.php
<style type="text/css">
.my_table{
margin-top:150px;
margin-left:400px;
}
</style>
<?php
if(!isset($_POST['send'])){
?>
<table align='center' class='my_table'>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<tr><th></th><th align='left'>Student Marks</th></tr>
<tr><td>enter subject</td><td><input type='text' name='subject'></td></tr>
<tr><td>enter marks</td><td><input type='text' name='marks'></td></tr>
<tr><td colspan='2' align='right'><input type='submit' value='submit' name='send'/> </td></tr>
</form>
</table>
<?php
}
else{
include 'array.php';
$svtoarray=new SaveMarks();
$svtoarray->addToArray($_POST['marks']);
$svtoarray->printArray();
}
?>
array.php
<?php
class SaveMarks{
static $index=0;
function SaveMarks(){
}
static $marks=array();
function addToArray($value){
$marks[$index]=$value;
$index++;
}
function printArray(){
$countarr=count($marks);
for($ind=0;$ind<$countarr;$ind++){
print $marks[ind];
}
}
}
?>
$ _POST 자체는 배열입니다. 왜 모든 복잡한 것들? –
나는'
은''