1
I made a list in which 6 elements initially appear and when you click on a button 4 more appear. The database only has 10 elements. the code is:
<div class="row">
<?php
$query=mysqli_query($db,"select id_album, nome, foto from albuns order by id_album ASC limit 6");
while($cat=mysqli_fetch_assoc($query)){?>
<div class="col-md-6">
<div class="portfolio-item">
<p class="imgDescription"> <?php echo $cat['nome'];?> </p>
<a>
<img class="img-portfolio img-responsive" src="<?php echo $cat['foto'];?>" onClick="location.href='listagem_album.php?id=<?php echo $cat['id_album'];?>'">
</a>
</div>
</div>
<?php } ?>
<?php
$query=mysqli_query($db,"select id_album, nome, foto from albuns order by id_album DESC limit 4");
while($cat=mysqli_fetch_assoc($query)){?>
<div class="col-md-6" id="fotos" style="display:none">
<div class="portfolio-item">
<p class="imgDescription"> <?php echo $cat['nome'];?> </p>
<a>
<img class="img-portfolio img-responsive" src="<?php echo $cat['foto'];?>" onClick="location.href='listagem_album.php?id=<?php echo $cat['id_album'];?>'">
</a>
</div>
</div>
<?php } ?>
</div>
<div id="button"><a class="btn btn-dark">View More Categories</a></div>
js button code is as follows:
<script>
$("button").click(function(){
$("#fotos").fadeIn(); });
</script>
Below is an image of the listing:
But when I click on the "show more Categories" button only one element appears. Thank you.
Good @Armando , worked! Before while I created a div without class, only with id="photos". And after while I kept the div class="col-Md-6" for css reasons. Thanks
– Claudia
Opa Claudia, but you can create with class Tbn will not affect anything for jquery because you are using the "ID" of div, but will affect everything in your layout with bootstrap.
– Armando Marques Sobrinho