in reply to Re: Calculating previous/next from database
in thread Calculating previous/next from database

Not quite. What you have won't return all the records in the table when called repeatedly. For that you need
SELECT * FROM images WHERE id > ? ORDER BY id LIMIT 1