I put it all here, it shows as a paste... mind looking and maybe editing and giving me your link? :)
public function getTopics($cid)
{
require("database.php");
$cat_id = strip_tags($cid);
$query = $db->query("SELECT DISTINCT * FROM `forum_topics` INNER JOIN `forum_replies` ON `forum_topics`.`topic_id`=`forum_replies`.`reply_id` GROUP BY `forum_topics`.`topic_id` ORDER BY coalesce(`forum_replies`.`posted_on`, `forum_topics`.`posted`) DESC");
if ($query->rowCount()==0)
{
return "<p>No topics, yet...</p>";
}else{
$returns = "<table class='table table-striped'>";
$returns .= "<tr><th></th><th>Posted</th><th>Replies</th></tr>";
while ($row = $query->fetch(PDO::FETCH_ASSOC))
{
$returns .= "<tr><td><a href='topic?tid=".$row['topic_id']."'><h4>{$row['topic_title']}</h4></a><p>".substr($row['topic_body'], 0, 150)."...</p></td><td><h5>".User::getInformation($row['topic_starter'], "user_id", "username")."</h5><p>on {$row['posted']}</p></th><td><h4>N/A</h4></td></tr>";
}
$returns .= "</table>";
return $returns;
}
}
// Output: http://www.seriouslycode.com/category?cid=1
// "test" should be on top as it has the most recent reply... I am trying to make the "bumping" feature.