Welcome Guest, Not a member yet? Register   Sign In
Multi level menu from database (parent->child)
#5

[eluser]Twisted1919[/eluser]
I got it a bit wrong, here is the deal:
you are populating an $data array that you are passing forward, you do it here:
Code:
foreach($q->result() as $r){
            $data[$r->parent][] = $r->parent;
        }
        $menu=$this->build_menu($data);
So, $data is an array getting only numerical keys, so if you print it out it'll look like:
Code:
Array(
  1 => Array(
          0=>1//parent
       ),
  2 => Array(
          0=>2//parent
       )
);

Then you pass this array to your build_menu($data) method, in which, you are doing
Code:
foreach ($parent as $r) {
          $child = $this->build_menu($r->menu_id);//BUM

As you can see, menu_id is not defined, actually $r itself cannot be an object because $parent is not an array of objects rather an array having only numerical values.

[Never mind the example]

Be sure that the query brings the menu_id key in .


Messages In This Thread
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 10:36 AM
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 12:14 PM
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 01:28 PM
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 01:30 PM
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 02:00 PM
Multi level menu from database (parent->child) - by El Forum - 02-17-2011, 02:37 PM
Multi level menu from database (parent->child) - by El Forum - 02-18-2011, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB