I'm trying to get data from 2 tables, Question and Answers. I want the results to output like this:
- Question number 1
a. Option a
b. Option b
c. Option c
But the output to the screen is doing the about but it puts in 50 option a's, 50 option b's, and 50 option c's then moves onto number 2.
Any ideas?
thanks, chad
$getQuestions = mysql_query("SELECT Questions.* FROM Questions
WHERE Questions.TVolume=$TVolume
AND Questions.TNumber=$TNumber
ORDER BY Questions.QuestionNumber");
while ($row = mysql_fetch_array($getQuestions)) {
$thisQuestion=$row['QuestionNumber'];
printf ("<P><B>%s. %s</B></P>\n\n",$row['QuestionNumber'],$row['QuestionText']);
$getAnswers = mysql_query("SELECT Answers.,Questions. FROM Answers,Questions
WHERE Answers.TNumber=$TNumber
AND Answers.TVolume=$TVolume
AND Answers.QuestionNumber=$thisQuestion
ORDER BY Answers.Answer");
echo "<TABLE>\n\n";
while ($row1 = mysql_fetch_array($getAnswers)) {
printf ("<TR><TD VALIGN=TOP><INPUT TYPE=\"Radio\" NAME=\"Q %s\" VALUE=\"%s\"><B>%s.</B></TD>\n",$row1['QuestionNumber'],$row1['Answer'],$row1['Answer']);
printf ("<TD>%s</TD></TR>\n\n",$row1['AnswerText']);
}
echo "</TABLE>";
}