Hi all,
I want to display results from two tables.
In table one I have a list of questions with an id.
In table two I have a list of answers with three relevant answers for each question. The answers are linked to each relevant question by a question number field.
I want to display each question with its relevant answers.
How do I do that?
Here is my database query:
$query2 = "select answer_entry.answer from answer_entry, question_entry where answer_entry.questionnum = question_entry.id";
$result2 = mysql_query($query2);
And my whilw loop to display: This displays each question fine but it doesn't match the relevant answers. i.e. it displays all the answers after the first question! Why is this??
while($row = mysql_fetch_array($result))
{
echo '<p>'.($i+1).'. Question: </p>';
echo $row['question']. '<br />';
$i++;
while($row2 = mysql_fetch_array($result2))
{
echo $row2['answer']. '<br />';
}
}
Thanks.
Kevin.