In the below code - I am grabbing data from an API. It iterates through 20 cities, and each city has several pages, each page being a seperate xml document which is defined in the url.
The code does the following:
1) Grabs the xml
2) Checks how many pages there are ($totalpages)
3) Iterates through the pages while the current page number is <= to the total number of pages.
The issue I am having, is that the 2nd while loop works fine. But the program isn't iterating through the city numbers - it stops at 1 after going through all the pages for city number 1, and doesn't go on to city number 2.
I have not used ++ to increase variable citynumber and pagenumber as for some reason, that did not work (Ie: It didnt increase the variable by 1 - any hints on why that might be would be appreciated :)
The sleep() is issued due to flood control by the API server. It's quite strict so hence waiting over a minute for each iteration.
I am quite a PHP beginner, so please dont laugh :)
So - any reason why citynumber is not increasing?
Cheers
<?
$citynumber = 1;
while ($citynumber <= 20)
{
$xml_feed = 'http://somewebsite/api/data.xml?city=$citynumber';
// CURL stuff ommitted for brevity
$pagenumber = (Current page number pulled from above xml document);
$totalpages = (Number pulled from above xml document);
while($pagenumber <= $totalpages)
{
$xml_feed = "http://somewebsite/api/data.xml?city=$citynumber&page=$pagenumber";
// CURL stuff omitted
foreach ($blahblah->Table as $stuff)
{
// whole bunch of stuff to pull xml data - not related to while loops.
};
$pagenumber = $pagenumber + 1;
sleep(70);
};
$citynumber = $citynumber + 1;
};
?>