Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reply to Bravogolf in closed thread: thread434-1203802

Status
Not open for further replies.

jpadie

Technical User
Nov 24, 2003
10,094
FR
@bravogolf
in a 2006 thread (thread434-1203802) i believe that the answer has now changed. for example

Code:
$query = "select id, name, SQL_CALC_FOUND_ROWS from tablename offset 10 limit 10";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
 //do something with the recordset
}
echo "Number Rows = ".getNumberRows();

function getNumberRows(){
 return mysql_result(mysql_query("select found_rows()"), 0, 0);
}

in the above the number of rows can be obtained from the library function which, as you see, is independent of the limit query actually run. it is also markedly more efficient since the resultset of the unlimited query does not need to be passed to the client. the essential thing is to insert the SQL_CALC_FOUND_ROWS field in your sql code.

hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top