Here is a nice trick guys...

if you want to page the result of this query :

SELECT * FROM user;

turn it into this one:

SELECT SQL_CALC_FOUND_ROWS * FROM user LIMIT $offset,$limit;

so in the end all you have to do is to perform one single query and even
before fetching the rows you can call the mysql_num_rows() function and it
will return the number of total rows rather than just $limit.

cheers,

Alessandro


-----Messaggio originale-----
Da: Matt Matijevich [mailto:[EMAIL PROTECTED]
Inviato: giovedi 24 giugno 2004 21.41
A: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Oggetto: Re: [PHP] MYSQL Query results in pages


[snip]
Is this right? Is there other efficent way to do it?
What about if data changes (i.e. new records are added) while the user
browses through pages?
[/snip]

on each page do a:

SELECT count(*) FROM table WHERE your_condition

this will give you your total number of results

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to