问题描述
嗨
我最近遇到了一个非常乏味的问题,我无法在论坛类别中显示主题。我已经能够在论坛风格的表格中显示所有类别但是当我点击其中一个类别时,我收到以下错误,但我不明白我的代码中哪里出错了:
注意:未定义的索引:第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>';
}
}
}
}
}
推荐答案
这是我的代码:
And this is my code:
else
{
//display category data
while(
中的主题
这篇关于不能在我的php / SQL论坛中显示类别中的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!