How can I get the number of times the word "false" is repeated, in a column from mysql.
example:
id | read |
-------------
1 | false |
-------------
2 | true |
-------------
3 | false |
-------------
4 | false |
-------------
total = 3 times
I tried to make the query like this:
$query = mysqli_query($connect, "SELECT
(length(read)-length(replace(read ,'false','')))/5 as COUNT
FROM ge_mensajes_col");
$cant = mysqli_fetch_array($query);
$json = '{"newMSJ": [';
$char ='"';
$json .=
'{
"total":"'.$query.'"
},';
// buat menghilangkan koma diakhir array
$json = substr($json,0,strlen($json)-1);
$json .= ']}';
// print json
echo $json;
mysqli_close($connect);
But it does not work for me, I do not get the amount in the Json, it shows me empty.