I made a list in which initially 6 elements 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>
The js button code is as follows:
<script>
$("button").click(function(){
$("#fotos").fadeIn(); });
</script>
The following is an image of the listing:
ButwhenIclickthe"show more categories" button, only one element appears. Thank you.