Code Comments
Programming Forum and web based access to our favorite programming groups.Correct - LIMIT 30,2 would show 2 records starting with the thirtieth. :) Enjoy the long wend [and likely, given the day, your Thanksgiving!] Woo, I'm outta here soon too. - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -----Original Message----- From: Gryffyn, Trevor [mailto:TGryffyn@air-cargo-inc.com]=20 Sent: Wednesday, November 24, 2004 2:46 PM To: php-db@lists.php.net Subject: RE: [PHP-DB] how to implement "pages" of results Oh yeah.. LIMIT 30,2 would show 30 records starting with the second record. I knew I was forgetting something. Sorry for the misinformation. Trying to finish some stuff before leaving for the w
end, but wanted to at least give you a nudge before disappearing. Good luck! -TG > -----Original Message----- > From: Norland, Martin [mailto:Martin.Norland@STJUDE.ORG] > Sent: Wednesday, November 24, 2004 3:38 PM > To: php-db@lists.php.net > Subject: RE: [PHP-DB] how to implement "pages" of results >=20 >=20 > Basic example: (handwritten in email client, syntax errors may exist) >=20 > if (!isset($pagenum) || $pagenum < 0) { $pagenum =3D 0; } $range =3D 30; > $start =3D $range*$pagenum; > $end =3D $start + $range; > $limit =3D " limit $start, $end"; > $query =3D "select * from $table where host=3D'$somename'$limit"; >=20 > Then just pass the pagenum around. You'll probably want to > pull another > query that just gets the count(), and use that and some basic math to > make the page range(s) to create hyperlinks. >=20 > Cheers. >=20 > - Martin Norland, Database / Web Developer, International > Outreach x3257 > The opinion(s) contained within this email do not necessarily=20 > represent > those of St. Jude Children's Research Hospital. >=20 >=20 > -----Original Message----- > From: ragan_davis@colstate.edu [mailto:ragan_davis@colstate.edu] > Sent: Wednesday, November 24, 2004 2:20 PM > To: php-db@lists.php.net > Subject: [PHP-DB] how to implement "pages" of results >=20 >=20 > Hi, >=20 > I'm sure this is a common question, so please forgive if it's been=20 > posted before. >=20 > I have a select statement that selects records from a table: "select * > from $table where host=3D'$somename'" >=20 > I then propagate a table with the returned data. My goal is to only=20 > display 30 records per "page", with links on each page that take the=20 > user to the next and previous 30 records. I have played around with=20 > using "limit", but this seems to only get me the next 30. How to=20 > achieve the previous 30? It would be easy if the records returned=20 > were sequentially numbered...but, since I'm being selective in > which records > I return (host=3D$somename), this is not the case. The first row may be > 1, and the second row may be 10, etc. >=20 > Anyone have any ideas on how to solve this? >=20 > Thanks! >=20 > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >=20 > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >=20 --=20 PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.