Populating accordion with database results help

ange_666

New Member
I am building a system in which the user can build thre own navigation menu from a selection of catergories, the way it works is that is they click on 'Blog' they they can get an accordion titled 'Blog' and on expanding this they see all the blog titles, however as the moment, my application creates multiple accordions if there are multiple blog entries, so at the moment i have two blog entries and when the user slects 'Blog' they get to accordions, where as they should get one with all the titles in Controller:\[code\]public function category($content_id) { //$this->output->enable_profiler(TRUE); if (intval($this->uri->segments[4])){ $content_id = $this->uri->segments[4]; } else { $content_id = $this->uri->segments[7]; } $data['content'] = $this->site_model->get_content($content_id); $this->load->view("call", $data);}\[/code\]Model:\[code\] public function get_content($content_id) { $this->db->select('*'); $this->db->from ('content'); $this->db->join('categories', 'categories.category_id = content.categories_category_id', 'left'); $this->db->where ('categories_category_id', $content_id); $query = $this->db->get(); return $query->result_array();}\[/code\]View:\[code\] <?phpif(isset($content)) {// var_dump($content); foreach($content as $row) { echo "<h2 class='$row[category_name]'><a href='http://stackoverflow.com/questions/1991642/#'>$row[category_name]</a></h2>"; echo "<div class='$row[category_name]'><a href='http://stackoverflow.com/questions/1991642/index.php/home/get_content/$row[content_id]' class='contentlink'>$row[content_title]</a></div>"; }}?>\[/code\]How can I alter my code so for category the user selects only one accordion gets built put all the categories realted content is placed in that accordion?Hope this makes sense.
 
Back
Top