Hi, Trying to build my own simple-ish forum script, and i want to display 2 forum posts snippets inside each category on the default page. I thought i knew the code for it but when i do
$cat = mysql_query("SELECT * FROM forum_cat")or die(mysql_error());
$catresult = mysql_num_rows($cat);
for($count = 1; $count <= $catresult; $count++){
$rowcat = mysql_fetch_array($cat);
$get=$rowcat['cat_name'];
$latest = mysql_query("SELECT * FROM forum_question WHERE category='$get' ORDER BY datetime DESC LIMIT 2")or die(mysql_error());
$counttresult = mysql_num_rows($latest);
echo '<div class="box"><div id="title"><div class="icn"><div class="icons2_5"></div></div>'.$rowcat['cat_name'].'<i>'.$counttresult.'</i></div>';
for($count = 1; $count <= $counttresult; $count++){
$rowlatest = mysql_fetch_array($latest);
echo '<div id="block"><div class="title">'.$rowlatest['topic'].'</div>'.substr($rowlatest['detail'], 0, 200).'</div>';
}
echo '</div>';
$cat2=$rowcat['cat_name'];
}
the code sort of works, but will bring back hundreds of category with blank names, you can see what's happening, but you will need to stop the page loading because it just carries on http://titaniumdesign.gotdns.org/base/forum.php Thanks :)