Haveing a while statement inside another while statement
Posted: Tue Feb 24, 2004 6:31 am
For my website I'm making my own forums but I'm trying to make one function do like 60 things at once. I have a while statememt and that echoes the category of the forums. But inside that while statement under where it echeos the catagory I want to add another while statement to echo the forums in that specific category.
I have been fiddling around with it and my browser just kindof "ignores" the second while statement.
I have been fiddling around with it and my browser just kindof "ignores" the second while statement.
Code: Select all
<?php
while($category=mysql_fetch_array($results))
{
$categoryname = $category['name'];
echo "
<table border=1 cellpadding=0 cellspacing=0 width=100%>
<tr><td colspan=4><font size=4><b> $categoryname</b></font></td></tr>
<tr>
<td width=50><center><b> </b></center></td>
<td width=70%><B>Forum:</b></td>
<td><center><b>Posts</b></center></td>
<td><center><b>Recent Posts</b></center></td></tr>";
$fs = mysql_query("SELECT * FROM forums WHERE category='$categoryname'") or die(mysql_error());
while($forum = mysql_fetch_array($fs))
{
$fdate = $forum['date'];
$ftitle = $forum['title'];
$fposter = $forum['poster'];
$fname = $forum['forumn'];
$fdesc = $forum['description'];
echo "
<tr>
<td width=50><center>V/U</center></td>
<td width=70%><B>$fname</b><br><font size=2>$fdesc</font></td>
<td><center><b>$pcount</b></center></td>";
if(!$forum['date']) {
echo "<td><font size=2>No New Posts</font></td></tr>";
}else{
echo "
<td><font size=2>$fdate<br>
In: $ftitle<br>
By: $fposter</font></td></tr>";
}
}
echo "</table><br><br>";
}
?>