I'm trying to display questions from a MYSQL (database)questions and loop through them writing them out. Then while writing them out i'm trying to loop through another Result set(answers) and print our all the answers that realte to the recid of the question.
It seems to accomplish everthing i need accept it will only display the answers for question 1. Then it just displays the rest of my questions.
I have no idea what i wrong with my loops and why there not working...anybody help???
while ( $questiondata = mysql_fetch_array($rsquestion))
{$quesrecid=$questiondata['recid'];
$question=$questiondata['question'];
$questionid=$questiondata['questionnum'];
echo"<tr><td class=QuestionCell>$question</td</tr>";
while($answersdata = mysql_fetch_array($rsanswers))
{
$ansquesid = $answersdata['questionid'];
$answer = $answersdata['answer'];
if ($ansquesid == $quesrecid)
{ echo ("<tr><td class=AnswerCell>QuestionId: $quesrecid AnswerQuestiondId: $ansquesid Answer:$answer </td></tr>" }
}
}
It seems to accomplish everthing i need accept it will only display the answers for question 1. Then it just displays the rest of my questions.
I have no idea what i wrong with my loops and why there not working...anybody help???
while ( $questiondata = mysql_fetch_array($rsquestion))
{$quesrecid=$questiondata['recid'];
$question=$questiondata['question'];
$questionid=$questiondata['questionnum'];
echo"<tr><td class=QuestionCell>$question</td</tr>";
while($answersdata = mysql_fetch_array($rsanswers))
{
$ansquesid = $answersdata['questionid'];
$answer = $answersdata['answer'];
if ($ansquesid == $quesrecid)
{ echo ("<tr><td class=AnswerCell>QuestionId: $quesrecid AnswerQuestiondId: $ansquesid Answer:$answer </td></tr>" }
}
}