<?php
// This block grabs the whole list for viewing
include "storescripts/connect_to_mysql.php";
$cat=$_POST['cat'];
$sql = mysql_query("select * from categories,products_cat,products where categories.id=products_cat.cat_id and products.id=products_cat.prod_id and categories=$cat");
$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 />";
}
?>
我有这三个表:1)产品表:id,product_name,price,category,subcategory
2) 类别表:id,cat
3)products_cat表:cat_id、prod_id
我无法显示用户将从命令行输入的特定类别的产品 cat=x ,它只会给我这个错误:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/perzul12/public_html/beta/show.php on line 6
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/perzul12/public_html/beta/show.php on line 7
请帮我 !这是我这个月唯一的金钱来源,我做不到!