Well, to build my menu my menu I use a db similar structure like this
2 Services 0
3 Photo Gallery 0
4 Home
You need to use recursive functions for this. Technically, there's a few ways to do it, but recursion is really the best option here.
Here's the basic gist of how it would work:
function drawMenu ($listOfItems) {
echo "";
foreach ($listOfItems as $item) {
echo "- " . $item->name;
if ($item->hasChildren()) {
drawMenu($item->getChildren()); // here is the recursion
}
echo "
";
}
echo "
";
}
The properties and methods of $item are just examples, and I'll leave it up to you to implement these however you need to, but I think it gets the message across.