i have stored questions in questions table. qid, qtext.
answers in answers table. aid,atext,cans (correct ans)
i have displayed the questions and multiple answers from database. like this..
What is capital of India
1.Chennai (radio button)
2.Bangalore (radio button)
3.Delhi (radio button)
What is capital of England
1.London (radio button)
2.Paris (radio button)
3.Madrid (radio button)
This is the PHP code.
Code: Select all
$sql="SELECT * FROM questions, answers WHERE answers.qid = questions.qid";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
if ($row['qtext'] != $lastQuestion) {
echo "<p>" . $row['qtext'] . "</p><br />";
$lastQuestion = $row['qtext'];
}
echo "<input type='radio' name='".$row['qid']."' value='".$row['aid']."' />".$row['atext'];