While Loops <--- GRR!
Posted: Wed May 26, 2004 9:53 pm
This is a forum script i'm making for a personal website.
How come I can't execute a loop inside a loop? Well, hopefully you understand what i'm trying to do, anyone have any suggestions on how to better my situation?
Code: Select all
<?php
$fcat = "SELECT * FROM forum_categories";
$fcat = mysql_query($fcat);
echo "<table width="100%" cellspacing="0" cellpadding="0" border="0">";
While ( $cat = MySQL_fetch_array($fcat) ) {
$cname = $cat['fcat_name'];
$cid = $cat['fcat_id'];
echo "<tr>";
echo "<td colspan="3" align="left">$cname</td>";
echo "</tr>";
$fforum = "SELECT * FROM forum_forums WHERE forums_catid = '".$cid."' ORDER BY forums_id ASC";
$fforum = mysql_query($fforum);
while ( $lf = MySQL_fetch_array($fforum) ) {
$fid = $lf['forums_id'];
$fname = $lf['forums_name'];
$description = $lf['forums_description'];
echo "<tr>";
echo "<td align="left" width="55%"><a href="index.php?module=forum&action=forum&f=$fid">$fname</a><br>$description</td><td width="10%">Topics</td><td width="10%">Replies</td><td width="25%">Last Post</td>";
echo "</tr>";
}
}
echo "</table>";
?>