hope everyone is fine over there :)
i just wanted to ask how i can display only one question at a time from mysql table??
here is my code which is doing following things
1) selecting all questions and displaying them
what i want to do is
1) display only one question at a time on a webpage and if user press the next button it shows another question
2) i want to check which option he selected so that i could be able to check that option against the correct answer.. and put a (x) or (tick) in front of that question and then move to next....
i hope i explained my answer clearly enough. i just want a way to do these things as i am new to php and my sql. Thankyou :)
questions table has following fields : id|question|type (t/f or MCQs)|possible_opt_1|possible_opt_2|possible_opt_3|possible_opt_4|answer|evaluationid (used as a foreign key)
<?php
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// selecting the questions that are from the current evaluation.
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM questions WHERE (evaluationid=".$evaluationid.")");
echo "<form action='start-course-evaluation-action.php' method='post'>";
echo "<table border='1' style='width:500px;'> <br />";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo " <strong>" . $row['question'] . "</strong><br /><br /><br />";
if ($row['type'] === 'MCQs')
{
echo "<input type='radio' value='' />";
echo $row['possible_opt_1']; echo "<br />";
echo "<input type='radio' value='' />";
echo $row['possible_opt_2'];echo "<br />";
echo "<input type='radio' value='' />";
echo $row['possible_opt_3'];echo "<br />";
echo "<input type='radio' value='' />";
echo $row['possible_opt_4'];echo "<br /><br /><br />";
}
else {
echo "<input type='radio' value='' />";
echo $row['possible_opt_1']; echo "<br />";
echo "<input type='radio' value='' />";
echo $row['possible_opt_2'];echo "<br />";
}
echo "</tr>";
}
echo "</table>";
echo "</form>";
mysql_close($con);
?>