Hello, hope ur having a nice day
the following code is creating a form using "echo" from php, the page is saved as .php also, the problem is: the last 2 "while" statements aren't printing the $Math or $Student arrays because they cannot see them, the error I get is "Warning: Variable passed to each() is not an array or object in c:\inetpub\wwwroot\php tests\exam.php" and therefore arent processed in the next page "exam2.php" (not included here)
if anybody knows whats wrong with the syntax or sth, please help :) thnks
<body>
<form method="post" ACTION='exam2.php'>
<?php
$student = array("Albert", "Ivan", "Napoleon", "Simon", "Issac");
while(list (,$name) = each($student))
{
echo "What grade did $name get in Math?";
echo "<br><br>";
echo "<select name='Math[]' >
<option> Grade A </option>
<option> Grade B </option>
<option> Grade C </option>
<option> Grade D </option>
<option> Grade E </option>
</select>";
echo "<br><br>";
echo "<input type='hidden' name='Student[]' value='$name'>";
}
while(list ($index,$value) = each($Math))
{
echo "<br>$index - $value";
}
while(list ($index,$value) = each($Student))
{
echo "<br>$index - $value";
}
echo "<input type='submit'></form>";
?>
</body>