我目前在我的网站论坛方面的工作和主页应该显示一个子论坛,最新的线程/帖子,它的海报,和时间列表。
这是当前代码:
$getTopics = $db->prepare("
SELECT ForumTopic.*,
(SELECT GROUP_CONCAT(forum_threads.title, 'SEX', User.Username, 'SEX', User.Admin, 'SEX', forum_threads.date)
FROM forum_threads
JOIN User ON forum_threads.author_id = User.ID
WHERE forum_threads.id = (
CASE WHEN ForumTopic.LastPostReplyID = 1
THEN ForumTopic.LastPostThreadID
ELSE (
SELECT thread_id
FROM forum_replies
WHERE id = ForumTopic.LastPostReplyID)
END)) AS LastPostInfo
FROM ForumTopic
WHERE ForumTopic.CategoryID = 1
ORDER BY ForumTopic.ID ASC");
$getTopics->execute();
if ($getTopics->rowCount() == 0) {
echo '
<div class="content-box is-rounded-bottom">
No topics found.
</div>
';
} else {
foreach ($getTopics as $key => $gT) {
if ($key > 0) {
echo '<hr>';
}
echo '
<div class="forum-topic">
<div class="row">
<div class="col-sm-7 align-self-center">
<div class="topic-title"><a href="'.$serverUrl.'/forum/topic?id='.$gT->ID.'">'.htmlentities($gT->Name).'</a></div>
<div class="topic-description">'.htmlentities($gT->Description).'</div>
</div>
<div class="col-sm-1 text-center align-self-center">
<div>0</div>
</div>
<div class="col-sm-1 text-center align-self-center">
<div>0</div>
</div>
<div class="col-sm-3 text-right align-self-center">
';
if ($gT->LastPostThreadID != 1 && !empty($gT->LastPostInfo)) {
$PostInfo = explode('SEX', $gT->LastPostInfo);
$ThreadName = LimitTextByCharacters(html_entity_decode($PostInfo[0]), 23);
$ThreadPoster = $PostInfo[1];
$ThreadAdminLevel = $PostInfo[2];
$ThreadTime = $PostInfo[3];
echo '
<div><a href="'.$serverUrl.'/forum/thread?id='.$gT->LastPostThreadID; if ($gT->LastPostReplyID != 1) { echo '#'.$gT->LastPostReplyID.''; } echo '" style="font-size:13px;">'.$ThreadName.'</a></div>
<div style="font-size:13px;padding-top:2px;">by '; if ($ThreadAdminLevel > 0) { echo '<a href="'.$serverUrl.'/profile/'.$ThreadPoster.'/" style="color:#ec2b1d;font-weight:600;">'.LimitTextByCharacters($ThreadPoster, 12).'</a>'; } else { echo '<a href="'.$serverUrl.'/profile/'.$ThreadPoster.'/">'.LimitTextByCharacters($ThreadPoster, 12).'</a>'; } echo ', '.get_short_timeago($ThreadTime).'</div>
';
} else {
echo 'N/A';
}
echo '
</div>
</div>
</div>
';
}
}
相反,它只是不断向我抛出“找不到主题”的信息。有什么解决办法吗?
暂无答案!
目前还没有任何答案,快来回答吧!