i have a code that display 3 questions and multiple answers from database for user to select. after choosing the answers user will hit the submit button. its works fine.
Current Code:
<?php
$today=date("Y-m-d");
echo "<form method='post' id='submit' action='checkresult.php' dir='rtl'>";
$sql="SELECT * FROM cquestions where showdate='$today' limit 3";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
echo "<p>" . $row['cqtext'] . "</p>";
$sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
$result2=mysql_query($sql2);
while($row2=mysql_fetch_assoc($result2))
{
echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext'];
}
}
$tomorrow= date("Y-m-d", strtotime("tomorrow"));
$sql4="SELECT * FROM qupdate";
$result4=mysql_query($sql4);
$last_update=mysql_result($result4,"last_update");
if($last_update==$today)
{
$cqid=mysql_result($result,"cqid");
$update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 3";
mysql_query($update1);
$update2="update qupdate set last_update='$tomorrow'";
mysql_query($update2);
$sql3="SELECT * FROM qupdate";
$result3=mysql_query($sql3);
$last_update=mysql_result($result3,"last_update");
}
echo"<br>";
echo"<br>";
echo"<input type='submit' id='submit' name='submit' value='Submit Answers' />";
echo "</form>" ;
?>
Output of above code
question1
ans1, ans2, ans3, ans4
question2
ans1, ans2, ans3, ans4
question3
ans1, ans2, ans3, ans4
SUBMIT
i want make some changes. i want to make it to display 1st question in first page, and user clicks next then it must go to 2nd question, then 3rd question and finally submit button.
Expecting Output
page1
Question 1
ans1, ans2, ans3, ans4
Next
after choosing the ans user clicks next
page2
question 2
ans1, ans2, ans3, ans4
Next
page3
question 3
ans1, ans2, ans3, ans4
SUBMIT Button.
how to do it?