<?php
//get previous and next ids of current id using SQL query
echo "select field1, field2
, ( select min(id) from yourtable where id > t.id ) as next_id
, ( select max(id) from yourtable where id < t.id ) as prev_id
from yourtable as t where id = 937";
?>