I want to show a gallery section in my website.
There are 3 slides and in each slide I want to show 3 columns. The first column should be col-md-6 and second & third column should col-md-3. In first column I want to show only 1 image, and 2 images in the second & third columns.
I'm very confused about how to split bootstrap columns. I want to split columns, just like the following screenshot:
This is the html code that I want to create:
<div class="gallery-slick">
<div class="slide">
<div class="col-md-6">
<img src="g1.png" alt="1" />
</div>
<div class="col-md-3">
<img src="g2.png" alt="1" />
<img src="g3.png" alt="1" />
</div>
<div class="col-md-3">
<img src="g4.png" alt="1" />
<img src="g5.png" alt="1" />
</div>
</div>
<div class="slide">
<div class="col-md-6">
<img src="g6.png" alt="1" />
</div>
<div class="col-md-3">
<img src="g7.png" alt="1" />
<img src="g8.png" alt="1" />
</div>
<div class="col-md-3">
<img src="g9.png" alt="1" />
<img src="g10.png" alt="1" />
</div>
</div>
<div class="slide">
<div class="col-md-6">
<img src="g10.png" alt="1" /
</div>
<div class="col-md-3">
<img src="g12.png" alt="1" /
<img src="g13.png" alt="1" /
</div>
<div class="col-md-3">
<img src="g14.png" alt="1" /
<img src="g15.png" alt="1" /
</div>
</div>
</div>
This is the data which comes from the database:
Array
(
[0] = stdClass Object
(
[id] = 2
[photo] = upload/gallery/gallery_image_1836387580.png
)
[1] = stdClass Object
(
[id] = 3
[photo] = upload/gallery/gallery_image_1367321200.png
)
[2] = stdClass Object
(
[id] = 4
[photo] = upload/gallery/gallery_image_1422567964.png
)
[3] = stdClass Object
(
[id] = 5
[photo] = upload/gallery/gallery_image_2112675692.png
)
[4] = stdClass Object
(
[id] = 6
[photo] = upload/gallery/gallery_image_110346512.png
)
[5] = stdClass Object
(
[id] = 7
[photo] = upload/gallery/gallery_image_915229176.png
)
[6] = stdClass Object
(
[id] = 8
[photo] = upload/gallery/gallery_image_400191899.png
)
[7] = stdClass Object
(
[id] = 9
[photo] = upload/gallery/gallery_image_1354992115.png
)
[8] = stdClass Object
(
[id] = 10
[photo] = upload/gallery/gallery_image_1844003279.png
)
[9] = stdClass Object
(
[id] = 11
[photo] = upload/gallery/gallery_image_383841711.png
)
[10] = stdClass Object
(
[id] = 12
[photo] = upload/gallery/gallery_image_1783795689.png
)
[11] = stdClass Object
(
[id] = 13
[photo] = upload/gallery/gallery_image_1138891555.png
)
[12] = stdClass Object
(
[id] = 14
[photo] = upload/gallery/gallery_image_335457236.png
)
[13] = stdClass Object
(
[id] = 15
[photo] = upload/gallery/gallery_image_2106903436.png
)
)
Here is the code that I tried but I didn't succeed:
<?php
$gallery = $this-crud-getDataAll('gallery');
$i = 1;
foreach ($gallery as $photo) {
if ($i > 0 AND $i % 3 == 0) {
echo '<div class="row">';
echo '<div class="col-md-3">';
echo 'Cell '.$i;
echo '</div>';
echo '</div>';
}
$i++;
}
?>
