I've an empty MySQL pets table. When I use the following PHP code, it provides one(1).
$query = "SELECT COUNT(*) FROM pets";
$result = mysqli_query($connect,$query);
$total=mysqli_num_rows($result);
echo $total;
I've an empty MySQL pets table. When I use the following PHP code, it provides one(1).
$query = "SELECT COUNT(*) FROM pets";
$result = mysqli_query($connect,$query);
$total=mysqli_num_rows($result);
echo $total;
You get the count of the results as a result, there is no num_rows actually you are getting the properities of the result like that...
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) }