Jump to content

AshishMalaviya

New Members
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by AshishMalaviya

  1. model : --> function MenuSub(){ $this->db->select('*'); $this->db->where('page_parent_id', '0'); $query = $this->db->get($this->table); $i = 0; $sub = 0; foreach($query->result() as $row) { $parentitem[$i]['page_id'] = $row->page_id; $parentitem[$i]['page_menutitle'] = $row->page_menutitle; $parentitem[$i]['page_parent_id'] = $row->page_parent_id; // Sub Menu $this->db->select('*'); $this->db->where('page_parent_id', $parentitem[$i]['page_id']); $subquery = $this->db->get($this->table); foreach($subquery->result() as $row) { $subitem[$sub]['page_id'] = $row->page_id; $subitem[$sub]['page_parent_id'] = $row->page_parent_id; $subitem[$sub]['page_menutitle'] = $row->page_menutitle; $subparentitem[$sub]['page_parent_id'] = $row->page_parent_id; $sub++; } $i++; } $nav; $nav = array(); $nav['parent'] = $parentitem; $nav['sub'] = $subitem; $nav['subparent'] = $subparentitem; return $nav; } Controller :--> function index(){ $data['nav'] = $this->page->MenuSub(); } view :--> <?php foreach($nav['parent'] as $parent) { echo '<li><a name="'.$parent['page_id'].'">'.$parent['page_menutitle'].'</a>'; echo '<div>'; echo '<ul>'; foreach($nav['sub'] as $subitem) { if($parent['page_id'] == $subitem['page_parent_id']){ echo '<li><a name="'.$subitem['page_parent_id'].'">'.$subitem['page_menutitle'].'</a></li>'; }else{} } echo '</ul>'; echo '</div>'; echo '</li>'; } ?>
×
×
  • 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.