I have a form (basically a test) that the users has to fill in. The question nr I get from the MySQL table but I can not get the question number carried over to the answer.php file.
form
$sql1="SELECT * FROM ex_question WHERE test_name = '$tid' ORDER BY RAND() LIMIT 5";
$result1=mysql_query($sql1);
while($row1 = mysql_fetch_array($result1))
{
$test_name=$row1['test_name'];
$q_nr=$row1['q_nr'];
$q_type=$row1['q_type'];
$question=$row1['question'];
$option1=$row1['option1'];
$option2=$row1['option2'];
echo "<form method='post' action='answer.php'>";
echo "<P><strong>$q_nr $question</strong><BR>";
echo "<input type='radio' name='$q_nr' value='option1'>$option1<BR>";
echo "<input type='radio' name='$q_nr' value='option2'>$option2<BR>";
echo "<BR>";
echo "<BR>";
echo "</p>";
}
echo "<input type='submit' value='Send Form'>";
echo "</form>";
?>
answer.php
<?php
$q_nr = $_GET['q_nr'] ;
echo $q_nr;
?>
I assume you want to get all questions and display them on the one page and then submit all answers to answer.php? In that case you could:
And on answer.php: