I currently have this query
SELECT short_url,
type,
file_thumbnail,
file_embed,
media.id,
user,
media.file_u
Here's a couple key points your app should try to maintain:
Keeping those goals in mind, I'd recommend that on clicking the "next row" link, the page pulls the next row's ID, then redirects to the permalink for that row. So, for example:
http://example.com/media/1337/prev
should run:
SELECT id FROM media WHERE media.id < 1337 ORDER BY media.id DESC LIMIT 1
And redirect to, presumably, http://example.com/media/1336
.
http://example.com/media/1337/next
should run:
SELECT id FROM media WHERE media.id > 1337 ORDER BY media.id ASC LIMIT 1
And redirect to, presumably, http://example.com/media/1338
.