0
I want to set a button so that whenever I press the LOAD button + the limit 18 always adds +18.
EXAMPLE: $sql = "SELECT * FROM portfolio ORDER BY id DESC limit 18";
CLICKABLE BUTTON
$sql = "SELECT * FROM portfolio ORDER BY id DESC limit 36";
CLICKABLE BUTTON
$sql = "SELECT * FROM portfolio ORDER BY id DESC limit 54";
I put this limit to tidy up the layout and appear only 18 blocks on my site and always press +18 on the button.
CODE:
<div class="grid">
<?php
$servidor = 'localhost';
$banco = 'apixel_galeria';
$usuario = 'root';
$senha = '';
$link = @mysql_connect($servidor, $usuario, $senha);
$db = mysql_select_db($banco,$link);
if(!$link)
{
echo "erro ao conectar ao banco de dados!";exit();
}
$sql = "SELECT * FROM portfolio ORDER BY id DESC limit 18";
$query = mysql_query($sql);
while($sql = mysql_fetch_array($query)){
$id = $sql["id"];
$nome = $sql["nome"];
$tipo = $sql["tipo"];
$desc = $sql["desc"];
$menu = $sql["menu"];
$imageM = $sql["imageM"];
$imageF = $sql["imageF"];
?>
<div class="element-item <?php echo "$menu";?>" data-category="transition">
<a href="#portfolioModal54" class="portfolio-link" data-toggle="modal">
<img src="<?php echo "$imageM"?>" alt="project 2">
<div class="mask"> <div class="conteudo_mask" style="
transform: translateY(-50%);
top: 50%;
position: relative;
/* float: left; */
"> <h1><?php echo "$nome"?></h1> <div id="lin" style="
width: 200px;
"></div> <h2><?php echo "$tipo"?></h2> </div><h3 style="
transform: translateY(-50%);
top: 50%;
position: relative;
">VEJA <br><img src="images/mais.png" alt="mais" style="width: 20px;height: 19px;margin-bottom: -1px;margin-top: 3px;"></h3></div>
</a>
</div>
<?php
}
?>
</div>
<!-- BOTÃO CARREGAR MAIS-->
<div id="rend-more">
<button class="button bt1" style="width: 262px; height: 50px; border: 1px solid rgb(84, 128, 128); position: relative; top: 30%; left: 50%; transform: translateX(-50%); cursor: pointer; background-color: white;">
<h2 style="text-align: center;color:#4d8984;font-family: 'Gotham-Thin';float: left;font-size: 25px;padding-left: 30px;padding-top: 5px;">CARREGAR</h2>
<h3 style="padding-left: 5px;float: left;font-size: 25px;color:#4d8984;font-family: 'gotham-bold';padding-top: 5px;">+</h3></button>
</div>
What you want is called PAGINATION. See this tutorial and see if it helps you.
– user28595
It doesn’t make sense, you’ll be picking up all the values already obtained before each click. Keep the limit and change the WHERE to > the last ID caught in the previous click. Of course there will have to change the logic of the page to load dynamically, or make paginated.
– Bacco
so buddy, it’s dynamically, when he squeezes he already carries down the others.
– kaiquemix
Bacco did not understand how I will do it rs, could explain me?
– kaiquemix
'Cause I don’t see a Where in my code.
– kaiquemix