当我运行以下代码时,echo返回资源ID#10而不是数字,在我的情况下6.感谢任何帮助!
$result = mysql_query("SELECT COUNT(`category_id`) FROM `products_has_product_category`
WHERE `category_id`=1");
echo $result;
答案 0 :(得分:0)
使用函数mysql_fetch_object
或mysql_fetch_row
将查询结果转换为数据
$result = mysql_query("SELECT COUNT(`category_id`) as count FROM `products_has_product_category`
WHERE `category_id`=1");
$row = mysql_fetch_object($result);
$count = $row->count;
echo $count;