Sorry, the title was hard to phrase.
Using PDO, I have a database with 100 records. A random number of records are chosen at a time and the ID of the last used is saved. Each time it grabs that random number of records it picks up where it left off last time starting with the saved ID. Easy so far.
My problem is if the last ID use was 94 (of 100) and the number of records is 10. I get the next 6 OK. But then need to restart at ID 1 and keep looping.
I could do it at the end of my loop by determining I am at last record ID and doing a new query starting at ID 1. But it seems a bit clunky, any thoughts on a better method?
To head off a duplicate post close, How to get a random range of 10 records from a database without overlapping the end boundary? is about getting a random subset that happens to start near the end.