开发者

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

开发者 https://www.devze.com 2023-03-09 05:17 出处:网络
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.

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

精彩评论

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