I'm looping a question for the user with different numerical values for $i. They will input a quantity in the html form that is also looped. Upon them clicking submit, I would like to have an array (with the key ranging form [0] onwards) that stores their response to each particular variant of the question. However, with the code I have written, I only manage to store their last input with the key [0] as if it was the first element of the array. All the previous answers seem to be lost when I call print_r. Please, I would really appreciate it if anyone could point out why this is happening or how I could fix it.
<?php
for ($i=2; $i<=10; $i++)
{
print "question $i";
echo"<form action=\"mysqlranked.php\" method=\"post\">
<input type=\"text\" name=\"pools[]\" value=\"0\" maxlength=\"2\" size=\"2\">
</form>
<br>";
}
print "
<form>
<input type=\"submit\" name=\"formSubmit\" value=\"Submit\">
</form>";
if (isset($_POST["formSubmit"]))
{
$var = $_POST["pools"];
}
print_r($var);
?>
<?PHP ?>or even<? ?>