I'm writing a simple message board where you can reply to any thread and then reply to any reply and so on.... everything works well but is there a simple method to loop the query as this could potentiality go on and on and on
$rsql = "SELECT * FROM rotd_mb WHERE reply='N' ORDER BY dateTime DESC";
$result = runSQL($rsql);
while ($row = mysql_fetch_array($result)) {
echo "".$row[title]."";
$rsql2 = "SELECT * FROM rotd_mb WHERE reply='Y' AND replyID='$row[messageID]' ORDER BY dateTime DESC";
$result2 = runSQL($rsql2);
while ($row2 = mysql_fetch_array($result2)) {
echo "".$row2[title]."";
$rsql3 = "SELECT * FROM rotd_mb WHERE reply='Y' AND replyID='$row2[messageID]' ORDER BY dateTime DESC";
$result3 = runSQL($rsql2);
while ($row3 = mysql_fetch_array($result3)) {
echo "".$row3[title]."";
}
mysql_free_result($result3);
}
mysql_free_result($result2);
}
mysql_free_result($result);