Welcome Guest, Not a member yet? Register   Sign In
Arrays, tables and headache
#5

[eluser]coldKingdom[/eluser]
I have now come to a solution and i would like to share some with you all Smile

Model:
Code:
function get_gallery($user) {
        $this->db->from("tbl_gallery_albums");
        $this->db->where("album_user", $user);
        
        $query = $this->db->get();
        
        $albums = $query->result_array();
        
        foreach ($albums as $album):
        
            $this->db->from("tbl_gallery");
            $this->db->where("gallery_album", $album["album_id"]);
            
            $query = $this->db->get();
            
            $data[$album["album_name"]] = $query->result_array();

        endforeach;
        
        return $data;
    }

View
Code:
<?php
    foreach ($data["gallery"] as $key => $index):
        echo heading($key, 3);
        echo '<table cellspacing="0" cellpadding="0" style="float:left;"><tr>';

        $count = 0;

        foreach ($index as $item):
            $img_attr = array(
                'src' => '/uploads/pictures/small/'.$item["gallery_picture"],
                'alt' => '',
                'style' => "margin-right:3px;"
            );
            $link_attr = array(
                'rel' => "shadowbox[".$item['gallery_album']."]",
                'title' => ""
            );
            
            $count++;
            
            print "<td>";
            print anchor('/uploads/pictures/large/'.$item["gallery_picture"], img($img_attr), $link_attr);
            print "</td>\n";
            
            if (($count % 4) == 0):
                echo "</tr><tr>";
                $count = 0;
            endif;

        endforeach;
        
        echo "</table>\n";
    endforeach;
?&gt;

Thank you for a good forum!


Messages In This Thread
Arrays, tables and headache - by El Forum - 02-24-2008, 03:14 PM
Arrays, tables and headache - by El Forum - 02-24-2008, 03:38 PM
Arrays, tables and headache - by El Forum - 02-24-2008, 03:57 PM
Arrays, tables and headache - by El Forum - 02-24-2008, 04:28 PM
Arrays, tables and headache - by El Forum - 02-24-2008, 05:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB