mysql - Increment while loop only on button click (PHP)
one text
I am doing a project (mood tracker) and I want to track mood by asking questions. I want to display one question at a time on a page with the same options for all questions.
$sql = mysqli_query($conn, "SELECT * FROM `questions_tab`");
while($row = mysqli_fetch_array($sql))
{
$ques=$row['Question'];
$qid=$row['QuestionId'];
echo '<b>Question '.$qid.' ::<br /><br />'.$ques.'</b><br /><br />';
}
$qry=mysqli_query($conn, "SELECT * FROM `options_tab`");
while($row=mysqli_fetch_array($qry))
{
$option=$row['Options'];
$optionid=$row['OptionId'];
echo'<input type="radio" name="ans" value="'.$optionid.'"> '.$option.'<br /><br />';
}
echo'<br><button type="submit"> Submit</button></form>';
?>
The problem here is that it displays all the questions at the same time with only one set of options.
Source