Welcome Guest, Not a member yet? Register   Sign In
Join one to many
#2

[eluser]apodner[/eluser]
Here's a quick & dirty possibility (but the better solution is to set this all up as separate methods in a model):


Code:
$galleryQuery = $this->db->get('gallery');
foreach ($galleryQuery->result_array() as $key => $row) {
    $data[$key] = $row;
    $this->db->where('gallery_id', $row['id_gallery']);
    $imgQuery = $this->db->get('images');
    $data[$key]['images'] = $imgQuery->result_array();  
}
return $data;


View: ( I assume each gallery goes with one figure tag)

Code:
<?php
foreach($data as $gallery) { ?>
    <figure>
        &lt;?php
         foreach($gallery['image'] as $image) {
             /* code for whatever you do with each image in the figure */
         }
         ?&gt;
    </figure>

&lt;?php
}
?&gt;


Messages In This Thread
Join one to many - by El Forum - 11-27-2012, 01:10 PM
Join one to many - by El Forum - 11-27-2012, 09:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB