It might be a bit confusing but let me explain.
So I have this DB
ID | username | status
1 | Bob | On
2 | James | On
3 | Jack | Off
4 | Bob | Off
5 | Arthur | On
How can I echo all the names which include status on? I tried something like
$reponse = $pdo->query('SELECT username, COUNT(1) as CNT FROM users GROUP BY status;');
$donnees = $reponse->fetch();
foreach ( $reponse as $key => $value ) {
echo '<li><a href="#"><i class="fa fa-circle-o"> '.$value['username'].'</i></a></li>';
}
Expected result
Echo: Bob James Arthur
But it only prints out the 1st ID who is offline (in this case Jack).
Thank you
PS: I'm learning PHP/MySQL at this moment so I feel kinda lost, If you share an answer please explain why you use your code and where I was wrong thank you.