i need help trying to create a loop within a loop. i'm am trying to print out answers to questions. i have the questions in one table, and answers in another. i want it so it looks like:
question 1
answer
answer
answer
question 2
answer
answer
answer
My problem is i dont know where in the first loop, i need to put the code for the second loop
first loop prints out the question
<?PHP
for($i = 0; $i < $numofrows; $i++) {
$row = pg_fetch_array($result2); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"#666666\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#777777\">\n";
}
echo "
<p>".$row['questionno']."</p>
<p>".$row['question']."</p>
\n";
?>
second loop prints out the answers to that question
<?PHP
for($i = 0; $i < $numofrows2; $i++) {
$row2 = pg_fetch_array($result3); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"#666666\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"#777777\">\n";
}
echo "
<p>".$row2['answerno']. "–".$row2['answer']."</p>
\n";
}
}
?>
Any help would be great
Thanks