I been working on this script all morning to get it to group Threads in Categories..
now in database i have 2 categories which are test1 and test2 now in test1 there is only 1 record in test2 i have 3 but when i run the script i get both categories showing with (grouped which is good) but under both of them they both show 4 threads :S can someone help me Please..
category.php
<table width="100%" height="20" border="0" bgcolor="#CFC095" class="Header_box" cellpadding="2" cellspacing="0">
<tr>
<th bgcolor="#514833" class="background_head" width="80%">Forum</th>
<th bgcolor="#514833" class="background_head" width="10%">Topics</th>
<th bgcolor="#514833" class="background_head" width="10%">Post</th>
</tr>
</table>
<?php
$get_category = mysql_query("SELECT * FROM header GROUP BY category") or die(mysql_error());
while($row = mysql_fetch_array($get_category)) {
?>
<table width="100%" height="20" border="0" bgcolor="#CFC095" class="Header_box" cellpadding="2" cellspacing="0">
<tr>
<th bgcolor="#514833" class="background_head" width="60%" align="left"><?php echo $row['category']; ?></th>
</tr>
</table>
<table width="100%" border="1" bordercolor="CFC095" cellpadding="3" cellspacing="0" bgcolor="#CFC095" class="Box_border">
<?php
$id = $_GET['id'];
$get_topic = mysql_query("SELECT id, heading, description FROM header ORDER BY category DESC") or die(mysql_error());
while($topic_info = mysql_fetch_array($get_topic)) {
$id = $topic_info['id'];
$heading = stripslashes($topic_info['heading']);
$description = $topic_info['description'];
$get_num_topics = mysql_query("SELECT forumid FROM forum_question WHERE forumid = $id");
$topics = mysql_num_rows($get_num_topics);
$get_num_posts = mysql_query("SELECT forumid FROM forum_answer WHERE forumid = $id");
$posts = mysql_num_rows($get_num_posts);
?>
<tr>
<td bgcolor="#4D4531" class="background" width="80%" align="left"><a href="../index.php?pages=topic&id=<?php echo $id; ?>"><?php echo $heading; ?></a><br /><?php echo $description; ?></td>
<td bgcolor="#4D4531" class="background" width="10%"><?php echo $topics; ?></td>
<td bgcolor="#4D4531" class="background" width="10%"><?php echo $posts; ?></td>
<?php
if($_SESSION['user_level'] == 5) {
?>
<tr>
<td bgcolor="#4D4531" class="background" align="right" width="60%"> </td>
<td bgcolor="#4D4531" class="background" align="right" width="10%"><a class="two" href="../index.php?pages=topic_edit2&id=<?php echo $id; ?>">Edit</a> | <a class="two" href="../index.php?pages=forum_functions&action=delete1&id=<?php echo $id; ?>">Delete</a></td>
<td bgcolor="#4D4531" class="background" width="10%"><a href="../index.php?pages=add_heading"><strong>Create New Subject</strong></a></td>
</tr>
<?php
}
}
}
?>
</table>
Thank you
Smackie