Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我运行以下代码时,回显返回资源 id #10 而不是数字,在我的情况下为 6。不胜感激!
$result = mysql_query("SELECT COUNT(`category_id`) FROM `products_has_product_category` WHERE `category_id`=1"); echo $result;
使用函数mysql_fetch_object或mysql_fetch_row将查询结果转换为数据
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;
见mysql_fetch_object