从数据库显示类别显示空结果

时间:2013-02-08 10:53:55

标签: php mysql

我有3个表,产品,类别和prod_cat 产品的id和类别的id与prod_cat id_cat和id_prod相关。

我想显示某个类别的产品来展示它,所以我写了这段代码:

$cat=$_POST['cat'];
$sql = mysql_query("SELECT products.id, products.product_name, products_cat.prod_id FROM products
INNER JOIN products_cat ON products.id=products_cat.prod_id ORDER BY products.id");
$catCount = mysql_num_rows($sql); // count the output amount
    while($row = mysql_fetch_array($sql)){ 
             $id = $row["id"];
             $product_name = $row["product_name"];
             $price = $row["price"];
             $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
             $prod_list .= "category ID: $id - <strong>$product_name</strong> <br />";

但是当我在页面上显示prod_list变量时它是空的,我做错了什么???

不过,我想这样显示:www.mydomain.com/show.php?cat = x

0 个答案:

没有答案