|
|
 |
RE: FN-FORUM: Choosing the next record in MySQL DB
date posted 14th May 2008 12:19
Graham Stark wrote:
> On Wed, 2008-05-14 at 11:33 +0000, Dom Latter wrote:
> Don't know why everyone wants to make this so complicated.
In the spirit of "more than one way to do it", I have to say I like the
earlier suggestion best, whereby you don't need to know the next and
previous id, you just pass a param back to the page to say current id and a
next flag and then the page changes the query accordingly e.g.
Page.php?id=8&next=1 (nextlink)
Page.php?id=8&prev=1 (previous link)
Then the page checks for next and prev params and query does e.g. "....where
id < $id limit 1" rather than usual "........where id = $id". This saves on
db access and has the (probably very marginal in most cases) extra benefit
that if the next and previous change before the link is clicked it is
handled dynamically (e.g. if next record is deleted between page loads it
doesn't cause a "not found").
Regards,
Dai
|
 |
|