$data[0][$row->parentid]['children'][$row->id] = $row->name
function getCategoriesNav(){
$data = array();
$children = array();
$this->db->select('id,name,parentid');
$this->db->where('status', 'active');
$this->db->orderby('parentid','asc');
$this->db->orderby('name','asc');
$this->db->groupby('parentid,id');
$Q = $this->db->get('categories');
if ($Q->num_rows() > 0){
foreach ($Q->result() as $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();
return $data;
}
please explain me
$data[0][$row->parentid]['children'][$row->id] = $row->name , where the children come from .
thanks in advance
mehdy
|