Hey guys,
The problem: I have a 3 question quiz which obtains the questions and answer options from a database. At the moment, I've managed to display all 3 questions on one page under one form.
What I'm trying to do: Display one question per page.
I've tried to google for help but only found one solution which is to use cookies, are there any other options?
I've included a snippet of my code here.
Thanks in advance for any help.
$query1 = "SELECT hWord, OPT_1, OPT_2, OPT_3, OPT_4, ANS FROM easyTab ORDER BY Rand() LIMIT 1";
$result1 = mysql_query($query1, $conn) or die(mysql_error());
while ($row = mysql_fetch_array($result1, MYSQL_NUM))
{
?>
<form name="quizgame1" method="post" action="checkquiztest.php?">
<ul class = "form">
<li>
Choose the closest meaning of this word:<br> <?php echo $row[0]; ?> <br><br>
<input type="radio" name="ans1" value="<?php echo $row[1]?>" title="<?php echo $row[1];?>" <br><br>
<input type="radio" name="ans1" value="<?php echo $row[2]?>" title="<?php echo $row[2];?>" /> <br><br>
<input type="radio" name="ans1" value="<?php echo $row[3]?>" title="<?php echo $row[3];?>" /> <br><br>
<input type="radio" name="ans1" value="<?php echo $row[4]?>" title="<?php echo $row[4];?>" <br>
<input type="hidden" name="correctanswer1" value="<?php echo $row[5]?>" />
</li>
</ul>
<?
}
$query2 = "SELECT hWord, OPT_1, OPT_2, OPT_3, OPT_4, ANS FROM easyTab ORDER BY Rand() LIMIT 1";
$result2 = mysql_query($query2, $conn) or die(mysql_error());
while ($row = mysql_fetch_array($result2, MYSQL_NUM))
{
?>
<form name="quizgame1" method="post" action="checkquiztest.php?">
<ul class = "form">
<li>
Choose the closest meaning of this word:<br> <?php echo $row[0]; ?> <br><br>
<input type="radio" name="ans2" value="<?php echo $row[1]?>" title="<?php echo $row[1];?>" <br><br>
<input type="radio" name="ans2" value="<?php echo $row[2]?>" title="<?php echo $row[2];?>" /> <br><br>
<input type="radio" name="ans2" value="<?php echo $row[3]?>" title="<?php echo $row[3];?>" /> <br><br>
<input type="radio" name="ans2" value="<?php echo $row[4]?>" title="<?php echo $row[4];?>" /> <br>
<input type="hidden" name="correctanswer2" value="<?php echo $row[5]?>" />
</li>
</ul>
<?
}
$query3 = "SELECT hWord, OPT_1, OPT_2, OPT_3, OPT_4, ANS FROM easyTab ORDER BY Rand() LIMIT 1";
$result3 = mysql_query($query3, $conn) or die(mysql_error());
while ($row = mysql_fetch_array($result3, MYSQL_NUM))
{
?>
<form name="quizgame1" method="post" action="checkquiztest.php?">
<ul class = "form">
<li>
Choose the closest meaning of this word:<br> <?php echo $row[0]; ?> <br><br>
<input type="radio" name="ans3" value="<?php echo $row[1]?>" title="<?php echo $row[1];?>" /> <br><br>
<input type="radio" name="ans3" value="<?php echo $row[2]?>" title="<?php echo $row[2];?>" /> <br><br>
<input type="radio" name="ans3" value="<?php echo $row[3]?>" title="<?php echo $row[3];?>" /> <br><br>
<input type="radio" name="ans3" value="<?php echo $row[4]?>" title="<?php echo $row[4];?>" /> <br>
<input type="hidden" name="correctanswer3" value="<?php echo $row[5]?>" />
</li>
</ul>
<?
}
?>
<p><center><input id="submitans" name="submitans" type ="submit" class="button white" value = "Submit"></center></p>