I'm trying to count the number of rows in a table and thought that this was the correct way to do that:
$result = $db->query("SELECT COUNT(*) FROM `table`;");
$count = $result->num_rows;
But counts always returns (int)1
. If I use the same query in phpMyAdmin I get the right result. It sits in a table so I tried testing $count[0]
as well, but that returns NULL
.
What is the right way to do this?