Chris,
It's simply(ish) a matter of changing the way that your next key works. You could do a select right at the begining and load all the sequential keys into an array. Then when the users presses next, you increment one through the array keys, resulting in the real ID value in your next select statement.
or:
Do a second read along the lines of :
select id from my_tab where id > (current_id) limit 0;
and store the id returned (which will be the next ID needed) into a variable which the next button uses.
Cheers
Justin