While Loop through pages
<p>I'm trying to get all the gameids for a particular player. The API I am working with only returns 24 games per page. I just cant figure out how to loop though the pages. </p>

<p><strong>The problem is adding 1 to $iPages so it can get the next page..</strong></p>

<p>My current script:</p>

<pre><code>&lt;?php
//incude sql database connection
include_once('sql.php');
//include api key 
include_once('api.php');
//gamertag
$gamertag = "jam1efoster";
//variant- Valid values are "Campaign", "Firefight", "Competitive", "Arena", "Invasion", "Custom", "Unknown". "Unknown" returns all games.
$variant = "Unknown";
//page number 0 = most recent
$iPage = 0;

while(!$endPages == "stop"){

$iPage = $iPage++;

$GetGameHistory = "http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/".$apiKey."/".rawurlencode($gamertag)."/".$variant."/".$iPage;

$output = file_get_contents($GetGameHistory);
$obj = json_decode($output);
echo $output;

$mPages = $obj-&gt;HasMorePages;
if($mPages == false){$endPages = "stop";}

foreach($obj-&gt;RecentGames as $recentgames) {
        $gameid = $recentgames-&gt;GameId;
        echo $gameid."&lt;br/&gt;";
    }

}
?&gt;
</code></pre>
