GlenR GlenR - 1 year ago 47
SQL Question

mysqli_num_rows is always 1

Can anyone tell me why this

$pages_query = mysqli_query($link, "SELECT COUNT(`id`) FROM `gallery`") or
$row = mysqli_num_rows($pages_query);
echo $row;

echos 1 even though there are 7 rows in my table?


That's because mysqli_num_rows() will return rows count :) and your query will return only one row (with count field).


$result = mysqli_fetch_array($pages_query, MYSQLI_NUM);

to get that count.