RE: [PHP] Previous & Next Navigation
| From: | Martin Towell | Date: | Tue, 04 Jun 2002 01:38:44 +0000 |
| Subject: | RE: [PHP] Previous & Next Navigation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100499@lists.php.net to get a copy of this message | ||
If you don't want to query the database again, you could always write the
results to a file.
There's a matter of cleaning up old cache files though, but that's not what
was asked... ;D
-----Original Message-----
From: Justin French [mailto:justin@indent.com.au]
Sent: Tuesday, June 04, 2002 11:40 AM
To: Jay Blanchard; php-general@lists.php.net
Subject: Re: [PHP] Previous & Next Navigation
Only querying the database once would result in you having to set a massive
session, cookie, or something to hold the whole result in.
Doesn't sound right to me... for starters, 3000 records / 30 per page = 100
pages... it seems unlikely that every user will make it through the 100
pages, so they (or the server) would be carrying around useless data.
What you want to do is limit each query to 30 results on each page, using
MySQL's LIMIT.
SELECT FROM table WHERE something ORDER BY id LIMIT 0,30 (first page)
SELECT FROM table WHERE something ORDER BY id LIMIT 30,60 (2nd page)
etc.
Justin French
on 04/06/02 3:06 AM, Jay Blanchard (jay.blanchard@niicommunications.com)
wrote:
> Howdy!
>
> I am working on a project where approximately 3k - 5k records are returned
> and need to be displayed 30 per page with 'previous' and 'next' navigation
> at the request of the users. Does anyone know of an efficient script that
> will do this in PHP (with MySQL) that will not query the database every
> time? I would like to place the records into an array after one query to
the
> database and then navigate the array...both for efficiency and speed.
>
> Anyhow, if anyone knows, please let me know. Otherwise I will have to
write
> what I am looking for, and I really have no desire to re-invent the whell
on
> a Monday afternoon.
>
> TIA!
>
> Jay
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php