0

当我运行以下代码时,回显返回资源 id #10 而不是数字,在我的情况下为 6。不胜感激!

$result = mysql_query("SELECT COUNT(`category_id`) FROM `products_has_product_category`
WHERE `category_id`=1");
        echo $result;
4

1 回答 1

0

使用函数mysql_fetch_objectmysql_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;

mysql_fetch_object

于 2012-10-04T21:44:13.607 回答