title: PHP loading items from the database into a div on load more button click
body: <p>I have a main.php page where I have a while loop that displays the first 10 items from the database. I want to load the next 10 items once a load more button is clicked.</p>
  
  <pre><code>$res = mysql_query("SELECT * FROM `posts` ORDER BY `date` DESC LIMIT 10");
  
  if($res &amp;&amp; mysql_num_rows($res) &gt; 0){
      while($row = mysql_fetch_assoc($res)){
          $id = $row['id'];
     ?&gt;
     &lt;div class="main_page"&gt;
          item id &lt;?php echo $id; ?&gt;
     &lt;/div&gt;
  
     &lt;button class="load_more"&gt;Load More&lt;/button&gt;
  </code></pre>
  
  <p>....</p>
  
  <p>What is a good way of doing this? Any help is much appreciated!</p>
  
  <p>UPDATE:</p>
  
  <p>right now i have this script for the load more button:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
     $(document).ready(function(){
          $(".load_more").click(function (){
              $('.load_more').html('&lt;img src="images/ajax-loader.gif" /&gt;');
              $.ajax({
                  url: "loadmore.php?id=" + $(".ad_display:last").attr("id"),
                  success: function(html){
                      if(html){
                          $(".main_page").append(html);
                          $('.load_more').html('Load More');
                      }else{
                          $('.load_more').replaceWith('No posts');
                      }
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>after the form of the filters is submitted, the url looks somewhat like this:
  index.php?search=&amp;category=0&amp;ad_order=1</p>
  
  <p>how do I pass on the search (even if empty), ad_order, and category value to the loadmore.php?</p>