working on a little problem here during my print out i get the table headers every single time and the bottom is never printed.
PHP:
<?php
$sql = "SELECT
category.`id`,
category.`category`,
topic.`title`,
topic.`id`,
topic.`about`,
topic.`lastpost`,
topic.`lastposttime`,
topic.`lastid`,
topic.`lasttopic`,
COUNT(DISTINCT postcounting.`id`) AS `topiccount`,
COUNT(DISTINCT replycounting.`id`) AS `replycount`
FROM `forum-category`
AS `category`
LEFT JOIN `forum-topics`
AS `topic`
ON
category.`id` = topic.`category_id`
LEFT JOIN `forum-posts`
AS
`postcounting`
ON
topic.`id` = postcounting.`post-id`
LEFT JOIN `forum-reply`
AS
`replycounting`
ON
postcounting.`id` = replycounting.`reply-id`
GROUP BY
topic.`id`
ORDER BY
category.`id`
";
///start result//
$result = mysql_query($sql) or die("Query failed($sql): " . mysql_error());
/// logic to handle the last category ///
$last_cat = '';
/// first counter for row colours///
$i = 0;
/// second counter for row colours ///
$m = 0;
/// start loop///
WHILE ($row = mysql_fetch_array($result)) {
/// if statement for handleing category rows///
if($row['category'] != $last_cat) {
$last_cat = $row['category'];
////The title of the block element (the catagory)////
printf( "<div class=\"title\"><h3>%s" . "</h3></div>", $row["category"]);
}
/// printing the rest of the table////
print "<div class=\"content\"><div class=\"content_text\">";
print '<table width="100%" border="0" cellpadding="3" cellspacing="0" >';
print '<tr class="page_title"><td width="50%">Forum</td><td width="10%">Topics</td><td width="10%">Replies</td><td width="30%">Last Posted by</td></tr>';
if($i++ % 2)
{
print '<tr class="wight">';
}
else
{
print '<tr class="other">';
}
printf("<tr><td><a href=\"forum_topic.php?id=%s&title=%s\">%s</a>" . "</td><td>%s" . "</td><td>%s" . "</td><td>%s" . "</td></tr>", $row["id"], $row["title"], $row["title"], $row["topiccount"], $row["replycount"], $row["lastpost"]);
/// the second row colour changer ////
if($m++ % 2)
{
print '<tr class="wight">';
}
else
{
print '<tr class="other">';
}
printf("<td><font size=\"-1\">%s" . "</font></td><td></td><td></td><td><font size=\"-1\">%s" . "<br /><a href=\"forum_topic_view.php?catagory=%s&title=%s&id=%s\">%s</a>" . "</font></td></tr>", $row["about"], $row["lastposttime"], $row["id"], $row["title"], $row["lastid"], $row["lasttopic"]);
/// finish the table ///
print '</table></div></div>';
}
$last_id = $row['about'];
if($row['about'] != $last_id) {
////the bottom////
print '<div class="bottom_content"><div class="btm_text">Add me</div></div>';
}
/////////////////////content ends////////////////////////
}
else {
///not logged in///
include("page_blocks/login.php");
/////////////////////content ends////////////////////////
}
?>