0

I'm hacking away at an API from which I'm parsing XML results files with PHP. Each XML result page displays 50 results max after the initial query. To see additional results, at 50 results per page, you must append ?pagenum=2, ?pagenum=3, and so on to the XML file URL.

So, my question is, how do I use PHP to automatically display results for subsequent pages until there are no additional page results left, after running the search query only once from front end input box? Instead of stopping at and displaying 50 results, all results possible should be displayed. Thanks

marswoody
  • 103
  • 5

1 Answers1

0

A simple way to do that is to count. Starting with zero and counting per each iteration, you just exit the loop if the counter reaches fiftyone.

At the beginning you do it the other way round, you first count down from the starting number to zero, then you start to process the inner of the loop.

Another possibility is to use the LimitIterator on an IteratorIterator on the Traversable you've got from Simplexml.

Also it is possible to do this via xpath.

All these are outlined here:

And further related to your question are:

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836