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:
<script>
$(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");
});
</script>
<div id="comnts"></div>
<button id="btn1">load more</button>
and this is the ld_comco.php file:
$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'];}
I do change the ld_comco.php
file for add repost button inside the posts:
$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'];
?>
<script>
$(document).ready(function() {
var recomco = 2;
var sbid = <?php echo $sbid?>;
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");
});
</script>
<?php }?>
<div id="recomnts"></div>
<button id="btn2">load more re-pst</button>
and add a ld_recomco.php
file:
$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'];
}
This dosen't work properly, how can I do this?
Edit: i have the user posts in a while-loop like this:
$qq="SELECT * FROM tbl_users_posts";
$qr=mysqli_query($conn,$qq);while($fff=mysqli_fetch_assoc($qr)){
$sbid=$fff['id'];
echo $fff['post'];}
i can add -load more- button to post but i cant add -load more- button to posts replay in some code like this:
$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'];?>
<?php $qq2="SELECT * FROM re_pst WHERE subid=$sbid";
$qr2=mysqli_query($conn,$qq2);while($fff2=mysqli_fetch_assoc($qr2)){
echo $fff2['remsg'];
}}