I have problem with mysqli_result() -> (ex mysql_result) (Call to undefined function mysqli_result() )
My code:
$per_page = 6;
$pages_query = mysqli_query($conn, 'SELECT COUNT(id) FROM users');
$pages = ceil(mysqli_result($pages_query, 0) / $per_page);
browser error:
Fatal error: Call to undefined function mysqli_result() in /Applications/MAMP/htdocs/bootstrap/pagination.php on line 11
Thanks in advance!
Updated:
As opposed to
mysql_result()
, there's nomysqli_result()
function available inMySQLi
. Now there are two approaches to solve your problem.Method(1):
Use
mysqli_fetch_array()
function to get the total number of rows. Your code should be like this:Method(2):
Alternatively, you can use
mysqli_num_rows()
to get the total number of rows from the result set. However, you need to change your query in the following way,So your code should be like this: