Jump to content

jaapjolman

New Members
  • Content Count

    3
  • Joined

  • Last visited

    Never

Community Reputation

0 Neutral

About jaapjolman

  • Rank
    Newbie

Profile Information

  • Gender
    Not Telling
  1. Controller: <?php function gui() { $nav = $this->site_model->navigation(); $page = $this->site_model->page_config(); $this->load->view('site/site',array('page' => $page, 'nav'=> $nav)); } ?> Model: <?php function navigation() { // Parent Menu $this->db->order_by('order', 'asc'); $this->db->where('subid', '0'); $query = $this->db->get('navigation'); $i = 0; foreach($query->result() as $row) { $parentitem[$i]['id'] = $row->id; $parentitem[$i]['link'] = $row->link; $parentitem[$i]['title'] = $row->title; // Sub Menu $this->db->order_by('order', 'asc'); $this->db->where('subid', $parentitem[$i]['id']); $subquery = $this->db->get('navigation'); $sub = 0; foreach($subquery->result() as $row) { $subitem[$sub]['id'] = $row->id; $subitem[$sub]['link'] = $row->link; $subitem[$sub]['title'] = $row->title; $sub++; } $i++; } $nav; $nav = array(); $nav['parent'] = $parentitem; $nav['sub'] = $subitem; return $nav; } ?> View: <?php foreach($nav['parent'] as $parent) { echo '<h3><a name="'.$parent['link'].'">'.$parent['title'].'</a></h3>'; echo '<div>'; echo '<ul>'; foreach($nav['sub'] as $subitem) { echo '<li><a name="'.$subitem['link'].'">'.$subitem['title'].'</a></li>'; } echo '</ul>'; echo '</div>'; } ?> the script works for the parent navigational links but not the sub links it keeps repeating the last subitem from the db I only posted the relivant portion of code
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.