[eluser]sihijau[/eluser]
Hi i create multi level category menu from database, category table structure:
-id
-parentid
-name
-url
i create methods in category model
method 1
Code:
function getActiveCategory(){
//$this->db->where('status','active');
$this->db->orderby('parentid','asc')->groupby('parentid,id');
$q=$this->db->get('categories');
foreach($q->result() as $r){
$data[$r->parentid][] = $r;
}
$menu=$this->getCategoryMenu($data,0);
return $menu;
}
method 2
Code:
function getCategoryMenu($category,$parent){
static $i = 1;
if ($category[$parent]) {
$menu = '<ul>';
$i++;
foreach ($category[$parent] as $r) {
$child = $this->getCategoryMenu($category, $r->id);
$menu .= '<li id="'.$parent.'">';
$menu .= '<a href="#">'.$r->name.'</a>';
if ($child) {
$i--;
$menu .= $child;
}
$menu .= '</li>';
}
$menu .= '</ul>';
return $menu;
} else {
return false;
}
}
when i call getActiveCategory on my controller method works, it show me list
* CLOTHES
o Shoes
+ Sport Shoes
o T-shirts
o pants
o dresses
o test2
* FUN
o toys
o games
+ PC Games
+ PS2 Games
* OTHER
but i got an error:
Quote:Severity: Notice
Message: Undefined index: 12
Filename: models/mcategory.php
Line Number: 61
Line 61 on my IDE point to
Quote:if ($category[$parent]) {
Could anyone help me please..?