rendered paste body$q = mysql_query("SELECT $a.name AS cat_name, $a.id AS cat_id, $b.name AS forum_name, $b.id AS forum_id, $b.category AS forum_category, $b.description AS forum_description FROM $a INNER JOIN $b ON $b.category=$a.id ORDER BY cat_id ASC, forum_id ASC");$selected_categories = array();echo '<div id="all">';while($r = mysql_fetch_assoc($q)){ if(!in_array($r['cat_name'], $selected_categories)) { echo '<div id="categoryname"> <a href="?nav=main&cat='.$r['cat_id'].'">'.$r['cat_name'].'</a> </div> <div id="forumdesc"> <table width="99%" border="0"> <tr> <td width="40%">Forum Name</td> <td width="20%" align="center">Topics</td> <td width="20%" align="center">Replies</td> <td width="19%"> Latest Post</td> </tr> </table> </div>'; } $topics = _count(prefix.'_posts', $r['forum_id']); $replies = _count(prefix.'_replies', $r['forum_id']); $title = getlastpost(prefix.'_posts', $r['forum_id']); $desc = empty($r['forum_description']) ? null : '<br /><span class="forumdesc">'.$r['forum_description'].'</span>'; echo '<div id="forumname"> <table width="99%" border="0"> <tr> <td width="40%"><a href="?nav=showforum&id='.$r['cat_id'].'&f='.$r['forum_id'].'">'.$r['forum_name'].'</a>'.$desc.'</td> <td width="20%" align="center">'.$topics.'</td> <td width="20%" align="center">'.$replies.'</td> <td width="19%">'.$title.'</td> </tr> </table> </div>'; $selected_categories[] = $r['cat_name'];} echo '</div>';