Re: using LIMIT

From: Date: Wed, 30 Aug 2000 22:13:00 +0000
Subject: Re: using LIMIT
Groups: php.general 
Request: Send a blank email to php-general+get-14476@lists.php.net to get a copy of this message
Thanks Tom, that is what I was looking for. Chuck Barnett -----Original Message----- From: Tom Walsh <TWalsh@achieversusa.com> To: 'Chuck Barnett' <xobyte@bellsouth.net>; php <php-general@lists.php.net> Date: Wednesday, August 30, 2000 11:26 AM Subject: RE: [PHP] using LIMIT >Actually the correct syntax is: > >LIMIT $offset, $number_of_records_to_return > >So: > >SELECT * FROM mydb WHERE name = 'John' LIMIT 20, 10 > >will return 10 users with name John starting from the 20th time John is >found... So in theory it would give you records 21-30... Now if you want to >do a listing of pages (Previous 10 and Next 10) you would do something like: > >$query = "SELECT * FROM $usertable LIMIT $offset, 10"; >$result = MYSQL_QUERY($query); >$next = $offset + 10; >$previous = $offset - 10; > >{blah} > ><A HREF=view.php?offset=$previous>Click here to see the previous 10 >records</A> > ><A HREF=view.php?offset=$next>Click here to see the next 10 records</A> > >And just FYI this info is covered at MySQL.com HOWEVER... Their >documentation is terrible when you compare it to what PHP offers so I can't >blame you for asking here. > >Tom Walsh >http://www.designgeek.com > > >> can anyone point me to some code on using LIMIT to make my >> data set smaller. >> >> THanks, >> Chuck >> >

« previous php.general (#14476) next »