COUNT(*) is no echo in WordPress

This is my var_dump result in WordPress but when I want to echo “COUNT(*)” this showed error reports.
Parse error: syntax error, unexpected ‘*’ in

But “package” is showed well. How can I echo each “COUNT(*)

My sql is:

$aaaaa = $wpdb->get_results( "SELECT package, COUNT(*) FROM $table_name GROUP BY package");

var_dump Result:

 array (size=5)
      0 => 
          public 'package' => string 'package 1' (length=9)
          public 'COUNT(*)' => string '1' (length=1)
      1 => 
          public 'package' => string 'package 3' (length=9)
          public 'COUNT(*)' => string '3' (length=1)
      2 => 
          public 'package' => string 'Package 4' (length=9)
          public 'COUNT(*)' => string '2' (length=1)


    echo  $aaaaa[2]->package;
    echo  $aaaaa[2]->COUNT(*);

Read more here: COUNT(*) is no echo in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *