I want to make a query for when I click the load more button, the LIMIT increases to display another 9 images in my gallery My Code:
<!-- connect.php -->
<?php
$host = "localhost";
$user = "root";
$db = "fenix";
$pass = "";
try{
$connect = new PDO("mysql:host=$host;dbname=$db",$user,$pass);
}catch(PDOException $e){
die("Error ".$e->getMessage());
}
<!-- index.php -->
<?php
require_once("connect.php");
?>
<script type="text/javascript">
$(document).ready(function(){
$("#carregar_mais").click(function(){
<?php $limite = $limite + 9;?>
});
});
</script>
<?php
$results = $connect->query("SELECT * FROM arquivo ORDER BY id_arquivo DESC LIMIT $limite");
?>
<div class="imagens">
<?php
while($row = $results->fetch(){ ?>
<a href="upload/uploads/<?php echo $row['nome_arquivo'];?>" >
<img class="imagem" src="upload/uploads/<?php echo $row['nome_arquivo'];?>" />
</a>
<?php } ?>
</div>
<center>
<p id="carregar_mais" style="color:white; cursor:pointer;">Carregar mais</p>
<?php echo $limite;?> <!-- Este echo é só para exibir em quanto está meu LIMIT-->
</center>
When loading the page, 9 images appear. When I click "load more" should appear another 9 (18). It's like an infinite scroll, but the user decides when to load more images.
Thank you!