R: [PHP] MYSQL Query results in pages
| From: | Alessandro Vitale | Date: | Fri, 25 Jun 2004 07:17:36 +0000 |
| Subject: | R: [PHP] MYSQL Query results in pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189035@lists.php.net to get a copy of this message | ||
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:matijevich@alliancetechnologies.net]
Inviato: giovedi 24 giugno 2004 21.41
A: php-general@lists.php.net; web_tur@yahoo.com
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