开发者

How to next next and previous ids in an ordered search when on a specific id? (MySQL)

I have an MLS site that you can search and it gives you a list of results. I then store the mysql string in a session.

When you c开发者_如何学JAVAlick on a result you go to the page listed by its property MLS number.

From that page I have a forward and backward button that is supposed to go back and forth through properties.

How do I use that same stored query string to find the next result and previous result depending on what property I am looking at?


Assuming the results are ordered by id, you could modify the stored query like this:

WHERE id > current_id LIMIT 1

to get the next property, where current_id is the id of the currently viewed record, and likewise:

WHERE id < current_id LIMIT 1

to get the previous one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜