mysqli_fetch_assoc, mysqli_fetch_row, mysqli_fetch_array and mysqli_fetch_object functions do always return an array or object when there is a(nother) row available. That is because a row can contain multiple columns. I like mysqli_fetch_assoc the most because you will get a associative array which is easier to understand by people. If there is a change that you would get more than one rows you should use a while loop like so:
while($row = mysqli_fetch_assoc($result) ) {
// do something with the $row array
}
If you expect ONE or NONE rows you can replace the while for a if.
if($row = mysqli_fetch_assoc($result) ) {
// do something with the $row array
}
However if you are 100% sure that there will be exactly one row you can also forget the whole if condition.
$row = mysqli_fetch_assoc($result) ;
// do something with the $row array
In all situations the $row variable will be an array (except with mysqli_fetch_object where you will get an object). So to get the variable that you want out of the array you will have to write something like:
echo $row['columnname']; // where columnname is the name of the column in the database table
In your case the columname would be something like $row['COUNT()']
. And if you doubt about the right columnname you could use a print_r($row);
or you could use an alias in your query e.g. SELECT COUNT() AS total
and use the same name in your associative array: $row['total']
.