Oh!  My mistake... I thought he was retrieving several listings at a
time...

If he's doing a single record each page, your method is definitely the
best that I can think of. :)


-----Original Message-----
From: scott [gts] [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, July 11, 2001 3:58 PM
To: php
Subject: RE: [PHP] Back/Forward


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:[EMAIL PROTECTED]]
> 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:[EMAIL PROTECTED]]
> 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:[EMAIL PROTECTED]]
> > Sent: Wednesday, July 11, 2001 2:53 PM
> > To: [EMAIL PROTECTED]
> > 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED] To 
> > contact the list administrators, e-mail:
> [EMAIL PROTECTED]
> > 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to