Forums

PHP

This topic is locked

Do while loop within a do while loop

Posted 17 Oct 2006 22:31:09
1
has voted
17 Oct 2006 22:31:09 Simon Bell posted:
I have what is probably a silly question, and I am probably attempting to approach this from the wrong angle from the start but...

I am using dreamweaver to create a forum, for which I have used Dreamweaver's built in server behaviours to repeat the a table with the forum topics on it. This appears to use a do while loop being drawn from a recordset that looks for the value '1' within a parentID column. I then have a separate recordset doing a Count of ID and grouping them by parentID.

What I am trying to do is to display the result of the count of ID within the repeated table currently I have attempted to use a do while loop (code bellow). Which repeatedly displays the result for the first.

<?php
do {
echo $row_recFMCount['CountOfintID'];
} while ($row_recForum['intID'] == $recFMCount['intParentID'])
?>

I have played around with trying to include the count query within the first recordset.

Any help would be greatly received. I have listed the table that the data is being drawn from an the queries.

Simon

tblForum
---------
intID integer (autonumber)
intParentID integer
txtSubject VARCHAR(255)
txtBody TEXT
txtAuthor VARCHAR(50)
dteCreated DATETIME


Recordsets:
--------------
recForum

SELECT *
FROM tblForum
WHERE tblForum.intParentID = '1'

--------------
recFMCount

SELECT tblForum.intID AS CountOfintID, tblForum.intParentID
FROM tblForum
GROUP BY tblForum.intParentID
HAVING (((tblForum.intParentID)<>0))

---------------

DW8 | PHP | MYSQL

Reply to this topic