How to convert a classic while loop to infinite scroll? -
i have while loop works great shows results. how can convert infinite scroll?
this actual code;
$query=mysql_query("select * images order image_id desc limit 10000"); echo '<table>'; while($row=mysql_fetch_array($query)){ . . . . . . } echo '</table>';
i've found answer! wants same thing;
$query=mysql_query("select * images order images_id desc limit 5"); echo '<table>'; while($row=mysql_fetch_assoc($query)){ echo '<tr>'; echo '<td> <div class="boxlatest" id="'.$imageid.'"> <div class="box"> <div id="content"> . . . . </div> </div> </div> </td> </tr>'; } echo '</table>'; echo '<div id="lastpostsloader"></div>'; to header.php;
<script type="text/javascript"> $(document).ready(function(){ function lastpostfunc() { $('div#lastpostsloader').html('<img src="bigloader.gif">'); $.post("indexajax.php?lastid="+$(".boxlatest:last").attr("id"), function(data){ if (data != "") { $(".boxlatest:last").after("<div class='newajax'>"+data+"</div>"); $(".newajax").hide().fadein("fast"); } $('div#lastpostsloader').empty(); }); }; $(window).scroll(function(){ if ($(window).scrolltop() == $(document).height() - $(window).height()){ lastpostfunc(); } }); }); </script> to indexajax.php;
$lastid=$_get['lastid']; $lastquery=mysql_query("select * resimler resim_id < '$lastid' order resim_id desc limit 5"); echo '<table>'; while($rowlast=mysql_fetch_assoc($lastquery)){ echo '<tr>'; echo '<td> <div class="boxlatest" id="'.$imageid.'"> <div class="box"> <div id="content"> . . . . </div> </div> </div> </td> </tr>'; } echo '</table>';
Comments
Post a Comment