To move to the next record, all you're doing is adding one. It has to have the ability to move to a specific record (returned from the query).

So basically you have an array of records returned by a query, and when you hit next, you have to grab that id value from the array by looping through it with a step counter variable.