无法在论坛类别中显示主题(PHP) [英] Cant display topics in a forum category (PHP)

查看:104
本文介绍了无法在论坛类别中显示主题(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我最近遇到了一个非常乏味的问题,我无法在论坛类别中显示主题。我已经能够在论坛风格的表格中显示所有类别但是当我点击其中一个类别时,我收到以下错误,但我不明白我的代码中哪里出错了:



注意:未定义的索引:第44行的... / category.php中的topic_cat



我想要获取与特定类别链接的主题(topic_cat链接到cat_id)。所以对于cat_id = 2,我想要分配了topic_cat = 2的所有主题。



以下是我的代码,任何人都可以看到任何问题吗?注意:这是当前正在处理的代码:



Hi
Ive been having a very tedious problem lately where Im not able to display the topics in a forum category. I have been able to display all categories in a forum-style table but when I click on one of the categories I am getting the following error but I dont understand where in my code it is going wrong:

Notice: Undefined index: topic_cat in .../category.php on line 44

I want to get the topics that are linked with a specific category (topic_cat links to cat_id). So for cat_id=2, I want all topics that are assigned topic_cat=2.

Below is my code, can anyone see any problems? Note: this is the code that is currently being processed:

else
        {
            if(mysql_num_rows($topicResult) == 0)
            {
                echo 'There are no topics in this category yet.';
            }





这是我的代码:





And this is my code:

    else
    {
        //display category data
        while($row = mysql_fetch_assoc($result))
        {
            echo '<h2>Topics in ′' . $row['cat_name'] . '′ category</h2>';
        }
     
        //do a query for the topics
        $topicSql = "SELECT 
                    topic_id,
                    topic_subject,
                    topic_date,
                    topic_cat
                FROM
                    topics
                WHERE
 44-->      topic_cat = '" . mysql_real_escape_string($_GET['topic_cat']) . "'";
         
        $topicResult = mysql_query($topicSql);
         
        if(!$topicResult)
        {
            echo 'The topics could not be displayed, please try again later.';
        }
        else
        {
            if(mysql_num_rows($topicResult) == 0)
            {
                echo 'There are no topics in this category yet.';
            }
            else
            {
                //prepare the table
                echo '<table border="1">
                      <tr>
                        <th>Topic</th>
                        <th>Created at</th>
                      </tr>';
                     
                while($row = mysql_fetch_assoc($topicResult))
                {              
                    echo '<tr>';
                        echo '<td class="leftpart">';
                            echo '<h3><a href="topic.php?topic_id=' . $row['topic_id'] . '">' . $row['topic_subject'] . '</a><h3>';
                        echo '</td>';
                        echo '<td class="rightpart">';
                            echo date('d-m-Y', strtotime($row['topic_date']));
                        echo '</td>';
                    echo '</tr>';
                }
            }
        }
    }
}

推荐答案

topicResult )== 0)
{
echo ' 此类别中没有主题。';
}
topicResult) == 0) { echo 'There are no topics in this category yet.'; }





这是我的代码:





And this is my code:

    else
    {
        //display category data
        while(


row = mysql_fetch_assoc(
row = mysql_fetch_assoc(


result))
{
echo ' < ; h2>''
result)) { echo '<h2>Topics in ′' .

中的主题

这篇关于无法在论坛类别中显示主题(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆