Okay. Think about it this way - each 'batch' is a different page. So have a variable to hold the page number, you'll want to initally set it to zero. Each time the 'next batch' button is pressed you'll want to increase this number. I'm not sure how you are accessing the database, but by having this variable it is easy to get each 'batch'. What you need is to be able to select which item numbers you want to get out of your database. Normally (with SQL for example), you tell the database the record to start at, and the record to end at, and it selects all the records between those two (including the start and end.)
Now you know you only want 8 items per page. So the difference between each start and end number needs to be 8.
So if you're 'starting number' was 0, and your 'end number' was 8, it would select records 0-8.
So you'll need two more variables, lowerLimit and upperLimit. Whenever the next batch button is pressed, you need to:
- Increase the 'batchNumber' by one.
- Make 'lowerLimit' equal to batchNumber * 8.
- Make 'upperLimit' equal to (batchNumber + 1) * 8.
Then you can just do something like this (this is SQL):
SELECT * FROM your_table LIMIT lowerLimit, upperLimit.
Edit: Similarly, for previous batch, all you need to do is recude 'batchNumber' by one, and then evaluate lowerLimit and upperLimit again.
I hope this has helped.
Post edited at 6:08 pm on June 17, 2009 by JamesBrauman