【发布时间】:2014-12-24 13:44:34
【问题描述】:
我从我的数据库中查询我正在处理的一个论坛。出于某种原因,我无法让 id 显示在链接中。我一直在绞尽脑汁想弄清楚。它适用于我的所有其他页面,除了这个。这是我正在使用的代码:
$topicsql = "SELECT topic_id,topic_subject,topic_date,topic_cat FROM topics
WHERE topic_cat = " . $row['cat_id'] . "
ORDER BY topic_date DESC LIMIT 1";
$topicsresult = mysqli_query($con, $topicsql);
if(!$topicsresult)
{
echo 'Last topic could not be displayed.';
}
else
{
if(mysqli_num_rows($topicsresult) == 0)
{
echo 'no topics yet';
}
else
{
while($topicrow = mysqli_fetch_assoc($topicsresult))
//Limit the number of characters in the latest topic link
$subject= substr($topicrow['topic_subject'], 0, 25);
$topic=$topicrow['id'];
echo '<a href="topic.php?id=' . $topicrow['topic_id'] . '">' . $subject . '…</a><br> on ' . date('m-d-Y', strtotime($topicrow['topic_date']));
}
}
当您将鼠标悬停在链接上时,我只会看到 topic.php?id=,但我应该会看到 topic.php?id=24
【问题讨论】:
-
请提及您在悬停时看到的内容。
-
当我将鼠标悬停在链接上时,我会看到 topic.php?id=......我应该看到 topic.php?id=24
-
请检查
topic_id是否在topicrow中;很可能你在弄乱名字。
标签: php database mysqli hyperlink