How to create dynamic menu and submenu using php and mysql

The easy way for now could be use two queries:

  • Select all menus which has parent_id=0
    (SELECT * FROM tblmenu WHERE parentid=0)
  • Loop through the result and again select the menus having the parent_id=PARENT_MENU
    (SELECT * FROM tblmenu WHERE parentid=parent_menu_id)

Hope you can manage the PHP code.

This is correct way.

looping while the condition matches in the parent list…