I want to display a list of categories with their corresponding forums, like every classic forum. Heres an example.
I found this piece of code on the internet, it kinda works but it doesnt close tables properly. Every category should have their own table, right now it only closes with one </table>
// Start the table here - outside the loop
echo '<table>';
// Here's how you track if you need the header
$lastCatID = -1;
// Now loop
foreach($query as $row)
{
// Only show cat header on condition
if ($lastCatID <> $row['cid']) {
echo '
<tr>
<th>' . $row['cat_name'] . '</th>
<th>Latest Reply</th>
<th>Topics</th>
<th>Posts</th>
</tr>';
// Note that you've shows this header so you don't show it again.
$lastCatID = $row['cid'];
}
// Now output the rest
echo '<tr>';
echo '<td width="55%">Link</a></td>';
echo '<td width="25%">User</td>';
echo '<td width="10%" align="center">23523</td>';
echo '<td width="10%" align="center">343235</td>';
echo '</tr>';
}
echo '</table>';