I want to make a photo gallery with 3 columns using Bootstrap. My gallery structure should be like this:
<div class="row">
<div class="col-4" id="box1">
<img class="img-fluid" src="images/image1.jpg">
<img class="img-fluid" src="images/image4.jpg">
</div>
<div class="col-4" id="box2">
<img class="img-fluid" src="images/image2.jpg">
<img class="img-fluid" src="images/image5.jpg">
</div>
<div class="col-4" id="box3">
<img class="img-fluid" src="images/image3.jpg">
<img class="img-fluid" src="images/image6.jpg">
</div>
</div>
Currently, I'm fetching the imageURL
all in the box1
div. But how can I fetch the images information and organise them in such a way that the 1st image URL value goes as a src
in the first div (box1
) and the 2nd in the box2
div, 3rd in the box3
div and 4th again in box1
and so on. How can I loop this logic?
<div class="row">
<?php
$imageQuery = $mysqli->query("SELECT imageURL FROM images WHERE album = 'UK' ORDER BY date ASC") or die($mysqli->error);
while ($rowImage = $imageQuery->fetch_array()) { ?>
<div class="col-4" id="box1">
<img class="img-fluid" src="<?php echo $rowImage['imageURL']; ?>">
</div>
<?php } ?>
</div>