0

I am interesting how can I do submenu with parent-child values in PHP.

My MySQL base is:

id | menu_id | menu | url | title | parent_id
---|---------|------|-----|------|------------
1  |1        |admin |index|home  | 0
2  |2        |admin |page |page  | 1

Etc.

From the base to collect the data by:

SELECT * FROM admin WHERE `menu` = "admin" ORDER BY menu_id ASC

and

SELECT * FROM admin WHERE `parent_id` = "id" ORDER BY menu_id ASC
3
  • 1
    Can you clarify what you mean by parent-child menu? are you talking about css dropdown menus? or about php arrays with keys and values? Commented Jun 28, 2016 at 14:50
  • 1
    It's called recursion: stackoverflow.com/questions/10782810/… Commented Jun 28, 2016 at 14:50
  • 1
    Use order by parent_id ASC Commented Jun 28, 2016 at 14:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.