how do i get mysql_num_rows from a php function
Posted: Sat Aug 25, 2012 1:28 pm
Hi everyone.
How do i get the mysql_num_rows from a php function; i wish to use the extracted number with my page pagination.
i know that if i do the following i will get the num rows.
i also know that if i place the same in a function i can simply question the Mysql Num rows after the query is run. e.g
two questions;
1. is this the correct way to get the num rows
2. if so , how do i extract the number from the PHP function.
is it possible to do two returns from a function. i.e
warm regards
andreea
How do i get the mysql_num_rows from a php function; i wish to use the extracted number with my page pagination.
i know that if i do the following i will get the num rows.
Code: Select all
$sql = mysql_query("SELECT id, FROM Members WHERE email_activated='1' ORDER BY id ASC");
$nr = mysql_num_rows($sql);
Code: Select all
function nationality_list ( )
{
global $dbc;
$select = " SELECT
id
$from = " FROM
Members ";
$query = $select.$from ;
$result = mysqli_query ($dbc, $query);
$nr = mysql_num_rows($result);
return $result ;
}
1. is this the correct way to get the num rows
2. if so , how do i extract the number from the PHP function.
is it possible to do two returns from a function. i.e
Code: Select all
$result = mysqli_query ($dbc, $query);
$nr = mysql_num_rows($result);
return $result ;
return $nr ;
andreea