codeigniter - having small problem wth this ci navigation script -



codeigniter - having small problem wth this ci navigation script -

my controller

[code]$data['navlist'] = $this->mcats->getcategoriesnav();[/code]

model is

[code] function getcategoriesnav(){ $data = array(); $this->db->group_by('parentid', 'id'); $q = $this->db->get('categories'); if($q->num_rows >0){ foreach($q->result() $row){ if($row->parentid > 0){ $data[0][$row->parentid]['children'][$row->id] = $row->name; }else{ $data[0][$row->id]['name'] = $row->name; } } } $q->free_result(); homecoming $data; } [/code]

and views is

[code]if(count($navlist)){ echo "<ul>"; foreach($navlist $key => $list){ foreach($list $topkey => $toplist){ echo "<li class='cat'>"; echo anchor("welcome/cat/$topkey", $toplist); echo "</li>\n"; if(count($toplist['children'])){ foreach($toplist['children'] $subkey => $subname){ echo "\n<li class='subcat'>"; echo anchor("welcome/cat/$subkey", $subname); echo "</li>"; } } } } echo "</ul>\n"; }[/code]

i not getting category name top menu, please help me on this,

it looks $data[0] used on 2 different places should $data instead, loading looped db results 1 array key, key 0

codeigniter

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -