所以,我有点让我的论坛碰撞......但是有一个明显的问题: 这是碰撞和在2个地方展示它...... 看一看: 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;
}
}