Hi,
I am trying to display a forum by the category the forum it exists. So what i need to do is display the forum category and display all the forums within that category and so on…
This is the page i am working on:
http://www.freemanholland.com/kidsintranet/public_html/coffee-break
I have the following code:
<div id="forum-layout">
<table class='tabulardata' cellspacing='0' rules='all'>
<tr>
<th align="left">Forum</th>
<th>Threads</th>
<th class="stat-width">Posts</th>
<th>Recently Posted</th>
</tr>
<?
$prevRow = null;
$i = 1;
while ($row = mysql_fetch_object($forums)) {
if ($prevRow !== null) {
if($row->name != $saveForumCategory) {
echo "<tr><td colspan='4' class='tdborder'><strong>$row->name</strong></td></tr>";
$cycle = false;
$saveForumCategory = $row->name;
}
} else {
echo "<tr><td colspan='4' class='tdborder'><strong>$row->name</strong></td></tr>";
$cycle = false;
$saveForumCategory = $row->name;
}
?>
<tr>
<td class="td-forumname"><a href='<?=__SITE_PATH?>coffee-break/topics'><?=$row->theName?></a><br/><?=$row->body?></td>
<td class='tdstats'>1</td>
<td class='tdstats'>1</td>
<td align="center">21 Apr 2010 01:11:58 PM</td>
</tr>
<?
$prevRow = $row;
$i++;
$i = $i % 2;
}
?>
</table>
</div>
</div>
I nearly have it working but as you can see the “Forum rules” category is displayed twice because there are 2 forums within it. So i need to have the forum category showing only once… Any ideas where i am going wrong?
This is the method i am using:
public function selectAllForums(){
$sql = "SELECT *, i.ID as theID, i.name as theName FROM forums i
INNER JOIN forum_category c ON c.ID = i.catID WHERE i.deleted = 0
ORDER BY i.date_added ASC";
$result = mysql_query($sql);
return $result;
}
Can someone please help me out?
Thanks