I have two records in my custom table. I am trying to use SELECT COUNT(*) AS total FROM tableA
but I am not getting the results I am expecting.
The code below will echo Array ( [0] => Array ( [total] => 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 );
The code below echos nothing:
// 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'];
How can I simplify this? What am I doing wrong? I'm racking my brain over this and I just can't get it to work.