所以,我的论坛有点工作了......但是有一个明显的大问题:它在两个地方出现了碰撞和显示......看看: http ://www.seriouslycode.com/category?cid=1
你会想看看“测试”——它是 1 个主题,2 个地方。
这是我的代码:
public function getTopics()
{
require("database.php");
//$cat_id = strip_tags($cat_id);
$query = $db->query("SELECT * FROM `forum_topics` LEFT JOIN `forum_replies` ON `forum_topics`.`topic_id`=`forum_replies`.`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;
}
}