我想从表单中获取输入并将其保存到php数组并打印数组。有两个文件,即array.php和marks.php。我想我搞砸了静态。请帮帮我!
标记.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();
}
?>
数组.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];
}
}
}
?>