【发布时间】:2013-10-21 14:28:53
【问题描述】:
我在 MySQL 表中有两条记录。我正在尝试使用SELECT COUNT(*) AS total FROM tableA,但没有得到我期望的结果。
下面的代码会回显Array ( [0] => Array ( [cnt] => 2 ) ):
// Count the amount of records in the table
$total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", 'ARRAY_A' );
echo "Total Records:" . print_r( $total );
下面的代码没有回应:
// Count the amount of records in the table
$total = $wpdb->get_results( "SELECT COUNT( * ) AS total FROM tableA", 'ARRAY_A' );
echo "Total Records:" . $total[0]['total'];
我怎样才能简化这个?我究竟做错了什么?我正在为此绞尽脑汁,但我无法让它发挥作用。
【问题讨论】:
标签: php mysql arrays wordpress associative-array