Infinite scrolling from xml
<p><strong>Dear Sirs,
I am loading an xml file with over 1000 records and the scheme of it is:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;deals&gt;

&lt;deal&gt;
&lt;deal_id&gt;1&lt;/deal_id&gt;
&lt;deal_title&gt; &lt;![CDATA[THE TITLE]]&gt; &lt;/deal_title&gt;
&lt;deal_description&gt; &lt;![CDATA[THE DESCRIPTION]]&gt; &lt;/deal_description&gt;
&lt;deal_url&gt; &lt;![CDATA[http://www.thedomain.com]]&gt; &lt;/deal_url&gt;
&lt;deal_price&gt;12.00&lt;/deal_price&gt;
&lt;deal_previous_price&gt;68.00&lt;/deal_previous_price&gt;
&lt;deal_discount&gt;82&lt;/deal_discount&gt;
&lt;deal_image&gt; &lt;![CDATA[http://www.thedomain.com/images/image.jpg]]&gt; &lt;/deal_image&gt;
&lt;deal_shop&gt;DEAL SITE NAME&lt;/deal_shop&gt;
&lt;/deal&gt;

&lt;/deals&gt;
</code></pre>

<p><strong>Unfortunately someone provides me this xml and  has no ordering.
Now i am using the code below to load my xml inside my php file 4 records from the xml:</strong></p>

<pre><code>&lt;ol class="timeline" id="updates"&gt;

&lt;?php

$url = "http://www.somedomain.com/xml.xml";
$xml = simplexml_load_file($url);
$bar_count = $xml-&gt;deal-&gt;count();


$limit = 0;
$num = 4;
foreach($xml-&gt;deal as $deal)
{

if($limit == $num)
break;



echo'
&lt;li&gt;
&lt;div class="dealmasterblock" id="'.$num.'"&gt;
&lt;div class="dealsite"&gt;'.$deal-&gt;deal_shop.'&lt;/div&gt;
&lt;div class="dealsimageblock"&gt;
&lt;div class="pricebg"&gt;
&lt;div style="width:55px; height:26px; float:left; margin-left:8px; margin-top:14px; font-family:Verdana, Geneva, sans-serif; color:#333; font-size:18px;"&gt;-'.$deal-&gt;deal_discount.'%&lt;/div&gt;
&lt;/div&gt;
&lt;div class="dealsimg"&gt;&lt;img src="'.$deal-&gt;deal_image.'" width="284" height="199" border="0" /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="others"&gt;
&lt;div class="dealtitle"&gt;'.$deal-&gt;deal_title.'&lt;/div&gt;
&lt;/div&gt;
&lt;div class="moreoptions"&gt;
&lt;div style="width:465px; height:34px; float:left; margin-top:3px;"&gt;
&lt;div style="width:180px; height:28px; padding-top:6px; float:left; font-family:Verdana, Geneva, sans-serif; background-color:#3189EE; color:#FFF; text-align:center; border-right:1px solid #0CF; margin-right:10px;"&gt;Αρχική τιμή: '.$deal-&gt;deal_previous_price.'€&lt;/div&gt;
&lt;div style="width:180px; height:28px; padding-top:6px; float:left; font-family:Verdana, Geneva, sans-serif; background-color:#3189EE; color:#FFF; text-align:center; border-right:1px solid #0CF;"&gt;Μόνο: '.$deal-&gt;deal_price.'€&lt;/div&gt;
&lt;/div&gt;
&lt;div style="width:147px; height:40px; float:right;"&gt;&lt;a href="'.$deal-&gt;deal_url.'" target="_blank"&gt;&lt;img src="images/morebtn.png" width="147" height="40" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;'; 

$limit++;
}

?&gt;
&lt;/ol&gt;

&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div id="more&lt;?php echo $num; ?&gt;" class="morebox"&gt;
&lt;a href="#" class="more" id="&lt;?php echo $num; ?&gt;"&gt;περισσότερα...&lt;/a&gt;
&lt;/div&gt;


&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p><strong>I have attached a jquery / ajax code to the button with class more so when i pressing it it will be load more records.
The jquery code is:</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){

$('.more').on('click', function(evt){

var ID = $(this).attr("id");

if(ID)
{

$("#more"+ID).html('&lt;img src="images/moreajax.gif" /&gt;');

$.ajax({
type: "POST",
url: "moredeals.php",
data: "lastmsg="+ ID, 
cache: false,
success: function(html){
$("ol#updates").append(html);
$("#more"+ID).remove();
//$('ol#updates').fadeIn("slow");
//alert('Return ok');
//$("#more"+ID).html('&lt;img src="images/moreajax.gif" /&gt;');
}

});
}
else
{
$(".morebox").html('The End');

}
return false;
});

});
&lt;/script&gt;
</code></pre>

<p>Moredeals.php that it is the ajax file to load more deals is:</p>

<pre><code>&lt;?php

$url = "http://www.somedomain.com/xml.xml";
$xml = simplexml_load_file($url);

if(isSet($_POST['lastmsg']))
{

$lastmsg=$_POST['lastmsg'];

$url = "http://www.clickbanner.gr/xml/?xml_type=deals&amp;affiliate_ID=16022";
$xml = simplexml_load_file($url);
$bar_count = $xml-&gt;deal-&gt;count();


$limit = 0;
$num = 8;
foreach($xml-&gt;deal as $deal)
{

if($limit == $num)
break;



echo'
&lt;li&gt;
&lt;div class="dealmasterblock" id="'.$num.'"&gt;
&lt;div class="dealsite"&gt;'.$deal-&gt;deal_shop.'&lt;/div&gt;
&lt;div class="dealsimageblock"&gt;
&lt;div class="pricebg"&gt;
&lt;div style="width:55px; height:26px; float:left; margin-left:8px; margin-top:14px; font-family:Verdana, Geneva, sans-serif; color:#333; font-size:18px;"&gt;-'.$deal-&gt;deal_discount.'%&lt;/div&gt;
&lt;/div&gt;
&lt;div class="dealsimg"&gt;&lt;img src="'.$deal-&gt;deal_image.'" width="284" height="199" border="0" /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="others"&gt;
&lt;div class="dealtitle"&gt;'.$deal-&gt;deal_title.'&lt;/div&gt;
&lt;/div&gt;
&lt;div class="moreoptions"&gt;
&lt;div style="width:465px; height:34px; float:left; margin-top:3px;"&gt;
&lt;div style="width:180px; height:28px; padding-top:6px; float:left; font-family:Verdana, Geneva, sans-serif; background-color:#3189EE; color:#FFF; text-align:center; border-right:1px solid #0CF; margin-right:10px;"&gt;Αρχική τιμή: '.$deal-&gt;deal_previous_price.'€&lt;/div&gt;
&lt;div style="width:180px; height:28px; padding-top:6px; float:left; font-family:Verdana, Geneva, sans-serif; background-color:#3189EE; color:#FFF; text-align:center; border-right:1px solid #0CF;"&gt;Μόνο: '.$deal-&gt;deal_price.'€&lt;/div&gt;
&lt;/div&gt;
&lt;div style="width:147px; height:40px; float:right;"&gt;&lt;a href="'.$deal-&gt;deal_url.'" target="_blank"&gt;&lt;img src="images/morebtn.png" width="147" height="40" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;'; 



$limit++;
}
?&gt;


&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;div id="more&lt;?php echo $num; ?&gt;" class="morebox"&gt;
&lt;a href="#" class="more" id="&lt;?php echo $num; ?&gt;"&gt;περισσότερα...&lt;/a&gt;
&lt;/div&gt;

&lt;?php
}
?&gt;

&lt;script type="text/javascript"&gt;
$(document).ready(function(){

$('.more').on('click', function(evt){

var ID = $(this).attr("id");

if(ID)
{

$("#more"+ID).html('&lt;img src="images/moreajax.gif" /&gt;');

$.ajax({
type: "POST",
url: "moredeals.php",
data: "lastmsg="+ ID, 
cache: false,
success: function(html){
$("ol#updates").append(html);
$("#more"+ID).remove();
}

});
}
else
{
$(".morebox").html('The End');
}
return false;

});

});
&lt;/script&gt;
</code></pre>

<p>Now the problem is that when more button is pressed i can load more 8 deals but is the same with 4 first records.</p>

<p>Any suggestions?</p>
