我試圖從mysql返回一個計數。我的代碼如下用COUNT(*)返回Mysql結果
$number_of_options_sql = tep_db_query("SELECT COUNT(*) FROM
(select sum(options_id) as total from products_attributes
where products_id='".$products_id."' group by options_id) as total");
$number_of_options_result = tep_db_fetch_array($number_of_options_sql);
當我運行在phpMyAdmin此查詢,它顯示了COUNT(*)
在表頭的結果。我得到正確的結果,查詢適用於我,我無法將其打印在屏幕上。
我試圖返回值通過以下方式和屏幕上沒有一個打印任何東西:後COUNT(*)
$number_of_options_sql = tep_db_query("SELECT COUNT(*) AS field_name FROM (select sum(options_id) as total from products_attributes where products_id='".$products_id."' group by options_id) as total");
echo $number_of_options_result[COUNT(*)];
echo $number_of_options_result[total];
缺少行情? – Bobby 2011-01-05 15:58:18