Re: Splitting Product Catalogue Over Multiple Pages?
| From: | Boa Constructor | Date: | Fri, 27 Jun 2003 15:21:47 +0000 |
| Subject: | Re: Splitting Product Catalogue Over Multiple Pages? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28949@lists.php.net to get a copy of this message | ||
RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?Ahhh rite, I think I get this,
I've just posted another question but I think I it will work if I do it the way I suggest in my
last post. If not please let me know.
Thank you both Gary and Michael!
Cheers,
Graeme :)
----- Original Message -----
From: Gary.Every@ingramentertainment.com
To: mickel@ntlworld.com ; php-db@lists.php.net ; Gary.Every@ingramentertainment.com
Sent: Friday, June 27, 2003 3:44 PM
Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
LIMIT 0,10 will return the first ten records of a result set. To make more sense, you should do an
ORDER BY of some field to get the info sorted correctly.
LIMIT takes 1 or two arguments
If there is only one argument, say 10, it will return the first ten records. If there are two
arguments, LIMIT 20,10 it will return 10 records starting at record 20.
More info at
http://www.mysql.com/doc/en/SELECT.html
Search for limit on that page.
Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:gary.every@ingramentertainment.com
http://accessingram.com
> -----Original Message-----
> From: Boa Constructor [mailto:mickel@ntlworld.com]
> Sent: Friday, June 27, 2003 9:20 AM
> To: php-db@lists.php.net; Gary.Every@ingramentertainment.com
> Subject: Re: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
>
>
> Gary, thanks for your reply, I think I'll need 2 have a think
> about this. I
> didn't totally understand:
>
> >You limit
> > the query by "LIMIT
> starting_point,number_of_records_to_return" at the end
> > of the sql statement.
>
> I've never used LIMIT before, could you explain this a bit
> more or point me
> to some info?
>
>
> Cheers,
>
> Graeme :)
>
>
> ----- Original Message -----
> From: <Gary.Every@ingramentertainment.com>
> To: <mickel@ntlworld.com>; <php-db@lists.php.net>
> Sent: Friday, June 27, 2003 2:39 PM
> Subject: RE: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
>
>
> > If you're trying to do paging, it's quite simple (there are tons of
> examples
> > out there, search google for paging php)
> >
> > $sql = "select count(*) from table_name"
> >
> > $number_of_records = mysql_query($sql);
> > $pointer=0;
> > $recs_per_page=20;
> >
> > if($number_of_records > $recs_per_page) {
> > // do a limit and keep the pointer
> > $sql = "select * from other_table limit $pointer,$recs_per_page";
> >
> > $pointer += $recs_per_page;
> >
> >
> > This isn't complete by any means but the point should be
> clear. You limit
> > the query by "LIMIT
> starting_point,number_of_records_to_return" at the end
> > of the sql statement.
> >
> > Don't worry about the values in the column, just the amount
> of records you
> > want to return
> >
> >
> >
> > Gary Every
> > Sr. UNIX Administrator
> > Ingram Entertainment
> > (615) 287-4876
> > "Pay It Forward"
> > mailto:gary.every@ingramentertainment.com
> > http://accessingram.com
> >
> >
> > > -----Original Message-----
> > > From: Boa Constructor [mailto:mickel@ntlworld.com]
> > > Sent: Thursday, June 26, 2003 10:25 PM
> > > To: php-db@lists.php.net
> > > Subject: [PHP-DB] Splitting Product Catalogue Over Multiple Pages?
> > >
> > >
> > > Greetings all, I'm not sure if this has been discussed
> > > recently, I've read
> > > bits and pieces and I can't remember where I read everything
> > > so if it has
> > > been brought up recently - sorry.
> > >
> > > If I do an SQL (MySQL) query on the first example to get the
> > > min and max IDs
> > > then I will get 1 and 6 respectively. I will then be able to
> > > loop from 1 to
> > > 6 and return all 6 products from the database. If however I
> > > wanted to split
> > > this in to two pages with 3 items in each page then using the
> > > first example
> > > below I could grab the min ID and add 2 to it to make 3. I
> > > could not do
> > > this using the second example because if I grab the min ID I
> > > would get 3, if
> > > I add 2 to it then I would get 5. 5 does not exit in this
> > > table so that
> > > wouldn't work. How in example 2 would I be able to split
> > > this over two
> > > pages?
> > >
> > > //example 1
> > >
> > > ID Product_Name
> > > 1 Hoover
> > > 2 Kettle
> > > 3 Fridge
> > > 4 Cooker
> > > 5 Food Mixer
> > > 6 TV
> > >
> > > //example 2
> > >
> > > ID Product_Name
> > > 3 Fridge
> > > 4 Cooker
> > > 7 Microwave Oven
> > > 8 Freezer
> > > 9 DVD Player
> > > 10 Computer
> > >
> > >
> > > Any ideas?
> > >
> > > Anything is much appreciated.
> > >
> > > Graeme :)
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>