Jump to content

Going to the Previous row in MySQL


Fmdpa

Recommended Posts

I'm creating a photo page, and there are navigation arrows on it. What I did (for the "previous photo" button) was to select the last ID (current id - 1) and fetch the url associated with that row. The query looked like this:

SELECT imageurl FROM images WHERE id="$currentID - 1"

It works flawlessly UNLESS the previous photo had been deleted. Then the id I have in the query refers to a non-existent row, which returns a bunch of errors. Is there a way I can easily select the previous id whether it is exactly "id - 1"?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...