title: php jquery mysql - load more button in another loadmore in loop
body: <p>I have two files for a load more button for posts but I can't use another load more for posts  replay
  this is one load more code:
  file index.php:</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
    var comco = 2;
    var offset = 0;
    $("#btn1").click(function() {
      $.ajax({
          method: "POST",
         url: "ld_comco.php",
          data: { comnco: comco, offset: offset }
        })
        .done(function(msg) {
          $("#comnts").append(msg);
        });
      offset = offset + comco;
    });
  
    $("#btn1").trigger("click");
  });
  &lt;/script&gt;
  &lt;div  id="comnts"&gt;&lt;/div&gt;
  &lt;button id="btn1"&gt;load more&lt;/button&gt;
  </code></pre>
  
  <p>and this is the ld_comco.php file:</p>
  
  <pre><code>$comnco=$_POST['comnco'];
  $offset=$_POST['offset'];
  
  $qq="SELECT * FROM tbl_users_posts limit $offset, $comnco";
  $qr=mysqli_query($conn,$qq);while($fff=mysqli_fetch_assoc($qr)){
      echo $fff['post'];}
  </code></pre>
  
  <p>I do change the <code>ld_comco.php</code> file for add repost button inside the posts:</p>
  
  <pre><code>$comnco=$_POST['comnco'];
  $offset=$_POST['offset'];
  
  $qq="SELECT * FROM tbl_users_posts limit $offset, $comnco";
  $qr=mysqli_query($conn,$qq);while($fff=mysqli_fetch_assoc($qr)){
     $sbid=$fff['id'];
      echo $fff['post'];
  ?&gt;
  
  &lt;script&gt;
  $(document).ready(function() {
    var recomco = 2;
    var sbid = &lt;?php echo $sbid?&gt;;
    var reoffset = 0;
    $("#btn2").click(function() {
      $.ajax({
          method: "POST",
         url: "ld_recomco.php",
          data: { recomnco: recomco, reoffset: reoffset }
        })
        .done(function(msg) {
          $("#recomnts").append(msg);
        });
      reoffset = reoffset + recomco;
    });
  
    $("#btn2").trigger("click");
  });
  &lt;/script&gt;
  &lt;?php }?&gt;
  &lt;div  id="recomnts"&gt;&lt;/div&gt;
  &lt;button id="btn2"&gt;load more re-pst&lt;/button&gt;
  </code></pre>
  
  <p>and add a <code>ld_recomco.php</code> file:</p>
  
  <pre><code>$recomnco=$_POST['recomnco'];
  $reoffset=$_POST['reoffset'];
  $sbid=$_POST['sbid'];
  
  $qq2="SELECT * FROM re_pst WHERE subid=$sbid limit $reoffset, $recomnco";
  $qr2=mysqli_query($conn,$qq2);while($fff2=mysqli_fetch_assoc($qr2)){
      echo $fff2['id'];
      echo $fff2['remsg'];
  }
  </code></pre>
  
  <p>This dosen't work properly, how can I do this?</p>
  
  <hr>
  
  <p>Edit:
  i have the user posts in a while-loop like this:</p>
  
  <pre><code>$qq="SELECT * FROM tbl_users_posts";
  $qr=mysqli_query($conn,$qq);while($fff=mysqli_fetch_assoc($qr)){
     $sbid=$fff['id'];
      echo $fff['post'];}
  </code></pre>
  
  <p>i can add -load more- button to post but i cant add -load more- button to posts replay
  in some code like this:</p>
  
  <pre><code>$qq="SELECT * FROM tbl_users_posts limit 10";
  $qr=mysqli_query($conn,$qq);while($fff=mysqli_fetch_assoc($qr)){
     $sbid=$fff['id'];
      echo $fff['post'];?&gt;
  &lt;?php   $qq2="SELECT * FROM re_pst WHERE subid=$sbid";
      $qr2=mysqli_query($conn,$qq2);while($fff2=mysqli_fetch_assoc($qr2)){
          echo $fff2['remsg'];
      }} 
  </code></pre>