RE: [PHP-DB] display 4 at a time
| From: | Jen Swofford | Date: | Fri, 31 May 2002 02:19:59 +0000 |
| Subject: | RE: [PHP-DB] display 4 at a time | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19543@lists.php.net to get a copy of this message | ||
OK, that's perfectly do-able. It still just seems like a lot of database
hits, however. (Not that I'm arguing. ;) My approach had definitely been
"do-this-to-the-results-I-already-got" and not
"get-the-results-this-particular-way". Must remember to think outside my
self-defined box.
Thank you!
jen
> -----Original Message-----
> From: Julie Meloni [mailto:julie@thickbook.com]
> Sent: Thursday, May 30, 2002 9:04 PM
> To: Jen Swofford
> Cc: php-db@lists.php.net
> Subject: Re: [PHP-DB] display 4 at a time
>
>
> JS> What I'm trying to do is have the ability to page through the
> database just
> JS> 4 products at a time.
>
> Use the LIMIT clause in your SQL query:
>
> select * FROM products WHERE prod_cat = $cat_ID LIMIT 4
>
> For the paging, you would use LIMIT with an offset (starting
> point) and number of rows, like:
>
> page 1:
> select * FROM products WHERE prod_cat = $cat_ID LIMIT 0,4
> page 2:
> select * FROM products WHERE prod_cat = $cat_ID LIMIT 4,4
> page 3:
> select * FROM products WHERE prod_cat = $cat_ID LIMIT 8,4
>
> and so on.
>
> Your links could send the offset as part of the query string, so you
> just re-run the script and offset is dynamic.
>
>
> - Julie
>
> --> Julie Meloni
> --> julie@thickbook.com
> --> www.thickbook.com
>
> Find "Sams Teach Yourself MySQL in 24 Hours" at
>
> http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20