I'm sure I'm missing something simple but I just can't seem to figure this one out. I have a dynamic XML file that is too big to display all the information on one web page. So I need a way to split the information across multiple pages. I have used foreach but the pointer is reset each time I loop through.
the following works to display all on one page:
$target = file_get_contents('http://twitter.com/statuses/followers/'.$username.'.xml');
$twitters = new SimpleXMLElement($target);
foreach ($twitters->user as $twit) {
echo '<div style="width:200px;height:275px;overflow-y:scroll;border:2px black solid;padding:3px;float:left;word-wrap:break-word;">
<a href="http://www.twitter.com/'.$twit->screen_name.'" ><img class="twitter_followers" src="'. $twit->profile_image_url.'" title="'. $twit->name .'" alt="" border="none" ></a><br>
<div style="text-align:left;"><b>'.$twit->name.'</b><br>'.$twit->description.'<br><a href="'.$twit->url.'">Web Site</a>
<br><br>
<i>Most recent post:</i><br>
'.$twit->status->text.'
</div>
</div>';
}
however when I try to display only 10 at a time I get the same first 10 due to the counter resetting
$target = file_get_contents('http://twitter.com/statuses/followers/'.$username.'.xml');
$twitters = new SimpleXMLElement($target);
for($i=0;$i<10;$i++){
foreach ($twitters->user as $twit) {
echo '<div style="width:200px;height:275px;overflow-y:scroll;border:2px black solid;padding:3px;float:left;word-wrap:break-word;">
<a href="http://www.twitter.com/'.$twit->screen_name.'" ><img class="twitter_followers" src="'. $twit->profile_image_url.'" title="'. $twit->name .'" alt="" border="none" ></a><br>
<div style="text-align:left;"><b>'.$twit->name.'</b><br>'.$twit->description.'<br><a href="'.$twit->url.'">Web Site</a>
<br><br>
<i>Most recent post:</i><br>
'.$twit->status->text.'
</div>
</div>';
}
}
I don't necesarily need to use WHILE. I am just looking for a way to display the XML data in groups of 10.