HI! I want to create a "Load more status" button att the bottom at the feed" right now as you can se from the code i've set a limit to 20 posts.
What im looking for is A Jquery or javascript function (maybe AJAX) that changes the
$statusQ = "SELECT * FROM `status` order by id desc LIMIT 20";
to
$statusQ = "SELECT * FROM `status` order by id desc LIMIT 40";
I Just want to change the LIMIT and refresh the request to the server without updating the HTML, javascript and CSS.
IS there a good way to do this.
Pls note that i've googled this alot and i've only found examples that not really good with my code.
<?php
$statusQ = "SELECT * FROM `status` order by id desc LIMIT 20";
$how_meny_rows = mysqli_query($mysqli, "SELECT * FROM `status`");
$row_cnt = mysqli_num_rows($how_meny_rows);
$statusA = mysqli_query($mysqli,$statusQ);
while ($row = mysqli_fetch_array($statusA)){
echo '<div class="statusholder">
<div class="status-img">
<img src="' . $row['Bild'] . '"/>
</div>
<div class="this-status">
<h4 class="status-who">'. $row['user'] .'</h4>
<p class="status">' .$row['status']. '</p>
<a class="status-like" href="javascript" onclick""> Gilla</a>
<p class="num_like comingsoon">' . $row['like'] . '</p>
<a class="status-comment" href="javascript" onclick"">Kommentera detta</a>
<p class="status-timestamp">' . $row['timestamp'] . '</p>
</div>
</div>';
}
if ($row_cnt > 20) {
echo '<div class="loadstatus">
<a href="javascript:void(0);" onclick="" class="comingsoon"> klicka för att ladda flerstatusar </a> </div>';
}
?>
LIMIT 0, 20Then move the 0 to a variable (it's an offset), and whenever you need more results, send x*number of items you want via Ajax to your script and then just append the output. This approach requires writing the Ajax request and the PHP code for managing it, though, and that falls in the category 'HTML/Javascript updating' - NorthBridge