there was a question, it is impossible to pull out the data, how to do it correctly?

$userdata = get_user_by( 'id', $user_ID ); $result = $wpdb->get_results(" SELECT COUNT(*) FROM `alu_user_reg` WHERE `user_group` = '" . $userdata->group . "'"); if ($result) { print_r($result); foreach ($result as $result){ echo $result-> COUNT(*); //так ругается } } 

It looks like an array

 Array ( [0] => stdClass Object ( [COUNT(*)] => 3 ) ) 

Thank!

  • one
    give the normal name to the result select count(*) as cnt ... - Mike
  • either select count(*) as cnt and $result->cnt or $result->{"COUNT(*)"} - teran

0