While statement help (PHP)
<p>My database contains both questions and answers. The questions have an ID (intQAID) and the responses have an ID (intResponseID). The intRespondID is the same as the intQAID ID that it is responding to. Each entry into the database has its own ID, which is intPostID.</p>

<p>What's i'm trying to do is write a query that will grab all this information and post it to a website using a while statement. However, the structure needs to be Question and underneath be the answer, until the while loop ends.</p>

<p>I can get the questions to post:</p>

<pre><code>$question = mysql_query("SELECT *,
(SELECT cUsername FROM tblUsers tblU WHERE Q2.intPosterID = tblU.intUserID) AS username, 
(SELECT DATE_FORMAT(dPostDateTime, '%b %e %Y %H:%i')) AS post_time 
FROM tblQA Q2 WHERE intResponseID = 0 
ORDER BY Q2.dSortDateTime DESC, Q2.intQAID DESC LIMIT 40");

while($row = mysql_fetch_array($question))
{
echo "&lt;tr class='forum'&gt;";
echo "&lt;td class='forum'&gt;" . substr($row['cBody'], 0, 150) . "&lt;/td&gt;";
echo "&lt;td class='forum'&gt;" . $row['cCategory'] . "&lt;/td&gt;";
echo "&lt;td class='forum'&gt;" . $row['username'] . "&lt;/td&gt;";
echo "&lt;td class='forum'&gt;" . $row['post_time'] . "&lt;/td&gt;";
echo "&lt;/tr&gt;";
}
</code></pre>

<p>But how can I get it to post the answer in the same while statement?</p>

<p>Should output like so:</p>

<pre><code>Question 1:
  Answer 1:
Question 2:
  Answer 2:
Question 3:
  Answer 3:
etc....
</code></pre>
