You need to count the number of entries in the users table, where action is 0, 1, 2, 3
if ($result = $mysqli->query('запрос')) { while( $row = $result->fetch_assoc() ) { To then use $row['count1']... through the function $row['count1']...
If it is right the way you want, in one record, then:
select sum(if(action=0,1,0)) count0, sum(if(action=1,1,0)) count1, sum(if(action=2,1,0)) count2, sum(if(action=3,1,0)) count3 from table Or:
select action,count(1) from table where action between 0 and 3 group by action At the output of the 4 resulting records with quantities, collect the array of values yourself or use the PDO functions to sample the finished array with the required structure
$result = $mysqli->query('SELECT * FROM users WHERE action = 0 OR action = 1 OR action = 2 OR action = 3 '); $count = mysql_num_rows($result); or you can immediately
"SELECT COUNT(id) FROM users WHERE action = 0 OR action = 1 OR action = 2 OR action = 3;" Source: https://ru.stackoverflow.com/questions/508882/
All Articles