如何将经典的 while 循环转换为无限滚动?

How to convert a classic while loop to infinite scroll?

我有一个 while 循环,效果很好,但它显示了所有结果。如何将其转换为无限滚动?

这是我的实际代码;

$query=mysql_query("select * from images ORDER BY image_id DESC limit 10000"); 

        echo '<table>'; 

   while($row=mysql_fetch_array($query)){ 
    .
    .
    .
    .
    .
    .
    } 
       echo '</table>'; 

我找到答案了!对于那些想做同样事情的人;

$query=mysql_query("select * from images order by 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>';

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>

indexajax.php;

$lastid=$_GET['lastid'];
 
 $lastquery=mysql_query("select * from resimler where resim_id < '$lastid' order by 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>';