Thanks I will try that. I took this code from old of my older websites and thinking of using it in my current project as finding some issues with how the navigation is used, its more of a logical issue, so hoping this approach will work.
By the way this block of code uses 1 single database table for categories which includes both parent and child menu items. Even though it works. Would you feel that's a bad approach, Could it cause potential issues further up the line?