[eluser]Unknown[/eluser]
I have to tables:
gallery ->
id_gallery, name, desc, data
and:
images ->
gallery_id, name,path
One gallery can have many images. I need to select all galleries and all images and on view page present all galleries and all images which contains that gallery. How can do this?
I have code like this for now:
Code:
$q = $this->db->select('*')->from('gallery')->join('images','images.gallery_id = gallery.id_gallery')->get();
return $q = $q->result_array();
And foreach loop in view:
Code:
<?php foreach ($gallery as $gal): ?>
<figure>
<a href="<?php echo IMG ?>galerija/<?php echo $gal['name'] ?>/<?php echo $gal['path'] ?>" rel="galerija[slike]" class="figure_img">
<img src="<?php echo IMG ?>galerija/<?php echo $gal['naziv'] ?>/thumbs/<?php echo $gal['path'] ?>" >
<figcaption><?php echo $gal['name']; ?></figcaption>
</a>
</figure>
<?php endforeach; ?>
This
foreach loop is producing 5
figure tags instead of one (if gallery have 5 images for example). I need to create one
figure tag, and inside it I need to create
a tag for every image in that gallery. How can I do this?