Database + flyout menu

I have a pretty complex problem. I am building a fly-out menu, which will be driven by a mysql database. This is the PHP code that should make it possible:

<?php function displayMenu($dID) { echo "
    "; $q = "SELECT * from db WHERE parent_id = $dID ORDER BY id"; $r = mysql_query($q) or die(mysql_error()); while ($row = mysql_fetch_array($r)) { if ($row['parent_id'] > 0) // is child echo ""; else // is parent echo "
  • ".$row['topic_name']."
  • "; displayMenu($row['topic_id']); } echo "
"; } displayMenu(0); ?>

Now my problem: WHen I want to display a GROUP of children, I have to add

    in front of the group, and
after the group. It shoul look something like this:
  • Parent 1
  • Parent 2
    • Child 1
    • Child 2
    • Child 3
  • Parent 3
    • Child 4
    • Child 5
      • Child 6
      • Child 7
    • Child 8
  • Parent 4

I hope this makes my problem clear. Can you help me?

Sponsor our Newsletter | Privacy Policy | Terms of Service