output result with SUM count

Asked by At

I have this query to my database it's working fine, I tested it in PHPMyAdmin. my problem is that I am trying to display the result in my page but I get blank output with no error

what am I doing wrong?

$count_fields = "SELECT SUM(agent_status = '1' ) AS 'agent'
    ,  SUM(agent_status = '0' ) AS 'agentoff'
     ,  SUM(admin_status = '0' ) AS 'admin'
      ,  SUM(user_id = '$id' ) AS 'user'
FROM property WHERE user_id = '$id'";
$count_res = $conn->prepare($count_fields);
$count = $count_res->fetchAll();

i created a foreach loop like

    foreach ($count as $cnt){
echo $cnt['agent']

but the result is blank...

1 Answers

SM Imtiaz Hussain On
foreach ($count as $cnt){
    echo $cnt['agent'] ;// please add ;