For a new import feature for my users, I'm using fgetcsv to read CSV files generated by social book cataloging sites like LibraryThing and Shelfari and then I run a series of Amazon queries to look up ISBNs from within the files. I want to be able to have users confirm the titles that match certain criteria, then add them to their local bookshelves.
Some of these files will have hundreds or thousands of records and I can't average more than 1 lookup per second with Amazon. I also want users to confirm we've matched their books correctly. I'm thinking that I should process the CSV file in chunks of 10 or 20 records, and display 'hits' for users to confirm. But I can't figure out how to do this effectively.
I can read the CSV file into an array, selecting only ISBNs, for example, and I know I can use a simple loop on the array to test 10 or 20 records against Amazon. But how do I allow the user to accept or reject the batch of records and then review 10 or 20 more without running fgetcsv again on the CSV file with a page reload?
Is there some simple way to allow an array to persist between page loads? Or perhaps I can pause to accept user input within the loop itself