我正在尝试创建一个包含categoryName 和categoryDescription 的链接。一旦我点击将我带到类别的链接,网址上的 cid 就不会显示,它应该有类似 cid=1 的内容。
这是已编写的代码...
<div id="content">
<?php
include_once("connection.php");
//category area
$sql = "SELECT * FROM ecommerce_category_table ORDER BY categoryName ASC";
$result = mysql_query($sql) or die(mysql_error());
$categories = "";
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$id = $row['$id'];
$name = $row['categoryName'];
$description = $row['categoryDescription'];
$categories .= "<a href='view_category.php?cid=".$id."' class='cat_link'>".$name." - ".$description."</a>";
}
echo $categories;
} else {
echo "<p>There are no categories avaliable yet.</p>";
}
?>
</div><!-- end content -->
最佳答案
在 while 循环中进行更改
$id = $row['$id'];
至
$id = $row['id'];
关于php - CID 在 PHP/MySQL 上不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15909426/