I currently have this query
SELECT short_url, type, file_thumbnail, file_embed, media.id, user, media.file_u
You can use subqueries to get the id of the previos and next record:
... where media.id in ( '$id', (select max(id) from media where id < '$id'), (select min(id) from media where id > '$id') ) ...