RE: [PHP] Back/Forward

From: Date: Wed, 11 Jul 2001 19:57:46 +0000
Subject: RE: [PHP] Back/Forward
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57479@lists.php.net to get a copy of this message
ah yes... that was my quick-n-dirty way ;) you could also do it this way: file.php?id=1&act=next if ($act eq 'next') { $sql = "SELECT id FROM table WHERE id > '$id' LIMIT 1"; } elsif ($act eq 'prev') { $sql = "SELECT id FROM table WHERE id < '$id' LIMIT 1"; } but that's also a quick-n-dirty way, becuase it doesnt know when the first/last record is... however, that's less quick and less dirty than the original code i posted.... TIMTOWTDI - there's more than one way to do it. :) > -----Original Message----- > From: Matthew Loff [mailto:matt@willetts.com] > Sent: Wednesday, July 11, 2001 3:59 PM > To: 'scott [gts]'; 'php' > Subject: RE: [PHP] Back/Forward > > > > > Since IDs can disappear when records are delted, I think it's best to do > a COUNT() first, then retrieve your listings with > > SELECT * FROM table WHERE blah LIMIT offset,number_to_retrieve; > > > -----Original Message----- > From: scott [gts] [mailto:scott@graphictype.com] > Sent: Wednesday, July 11, 2001 2:55 PM > To: php > Subject: RE: [PHP] Back/Forward > > > how do you have the data stored? > by ID number? > > if you have it stored by ID number, just > put next/back links something like this: > > <? > // here, find out the max number of rocks > $prev = (($id>0)? $id-1 : 0 ); > $next = (($id<$max)? $id+1 : $max ); > ?> > > <A HREF="rock.php?id=<?= $prev ?>">previous</A> > <A HREF="rock.php?id=<?= $next ?>">next</A> > > > > > -----Original Message----- > > From: Devin Atencio [mailto:dreamboy@aros.net] > > Sent: Wednesday, July 11, 2001 2:53 PM > > To: php-general@lists.php.net > > Subject: [PHP] Back/Forward > > > > > > > > I have a page that brings up the info on a rock, I wanted to add the > > functionality of doing like a <next> and <previous> option to go thru > > all the rocks in my database. I can't figure out how to exactly do > > this, could someone give me some help? > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#57479) next »