I have some text inputs. The inputs are produced from a while loop. Now I want put the values in an array. Like this:
array values
mark['0'] input1
mark['1'] input2
mark['2'] input3
I tried this but not working.
while($row=mysql_fetch_array($result)){
<form class="form1" name="form1" method="post">
<input type="text" name="mark[]"/>
</form>
}
<form class="form1" name="form1" method="post">
<button type="submit" name="correction"></submit>
</form>
And then
if(isset($_POST['correction'])){
$grade=0;
$mark=$_POST['mark'];
foreach($mark as $key =>$value ){
$grade+=$value;
}
print $grade;
}
I get these errors:
Notice: Undefined index: mark in C:\xampp\htdocs\virtual_exam\handy_correction.php on line 37
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\virtual_exam\handy_correction.php on line 38
The problem may be caused by two forms which arent connected to each other and if YES, how to joined them? If NO, how to do what i want?