I'm trying to create a questionnaire where I have eight questions. I'm not sure about how I should go about making one to begin with, as I have never attempted this before and can't find information online for my needs.
How do I create a form that has four sets of questions in a radio button. The four questions are sorted by an ID called question id (qid).
Currently I can make the four questions show, but I'd like it so that if you press the next button or the previous button on the form, you will be taken to the next or previous question pages.
My table columns are: qid (int), answer(varchar) and point (int).
There are eight question IDs and four answers have one set of qid (example answers 1-4 have id 1, answers 4-8 have qid 2. )
My code so far:
$qid1 = 1;
$sql1 = mysqli_query($connect,"SELECT * FROM question where qid ='$qid1'");
//if sats
//while sats
while($row=mysqli_fetch_assoc($sql1))
{
echo "<form method='post' action='kandidatdilemma?qid=2.php' name='question1'><input type='radio' name='answer[]' value='".$row['Point']."'>"
.$row['answer'] ."<br>";
}
if (isset($_POST['forward'])) {
$qid2 = 2;
$sql2 = mysqli_query($connect,"SELECT * FROM question where qid ='$qid2'");
echo "<form method='post' action='kandidatdilemma?qid=3.php' name='question2'>
<input type='radio' name='answer[]' value='".$row['Point']."'>"
.$row['answer'] ."<br></form>";
}
?>
<form name="questionnaire" method="POST">
<input type="submit" name="previous" value="Back">
<input type="submit" name="forward" value="Next" />
</form>