I want to generate a menu with the values from the database.
+------+------+------------+--------------------+--------------+----------+
| ID |Parent| Name | Link | Type | Order |
+------+------+------------+--------------------+--------------+----------+
| 1 | 0 | Some Name 2| /path1 | Top | 1 |
| 2 | 1 | Some Name A| /path2 | Custom | 1 |
| 3 | 0 | Some Name x| /path3 | Top | 2 |
| 3 | 1 | Some Name e| /path4 | Custom | 2 |
| 4 | 1 | Some Name 3| /path5 | Custom | 3 |
| 5 | 6 | Some Name t| /path6 | Custom | 1 |
| 6 | 0 | Some Name i| /path7 | Top | 3 |
+------+------+------------+--------------------+--------------+----------+
The Menu should look like:
<a href="/path1">Some Name 2</a>
- <a href="/path4">Some Name e</a>
- <a href="/path5">Some Name 3</a>
<a href="/path3">Some Name x</a>
<a href="/path7">Some Name i</a>
- <a href="/path6">Some Name t</a>
ID - is unique ID.
Parent - 0 means no parent, any other value represents the ID (above) of the parent item in the menu.
Name - The text for the respective item in the menu.
Link - The link of the respective item in the menu.
Type - Top means top level item in the menu, the rest are labeled as custom.
Order - For top items, sets the order how they appear in the menu 1 being first > bigger numbers. For sub-items sets the order how they appear in the respective list of sub items.
The menu has only one level: Top > Sub
What I need to do is find a way to generate a menu from these values in php & mysqli.
The problem is I have no idea how I should proceed.. I tried select concat for ID and Parent but I lack some basic php skills (total noob).
How should I proceed? Any idea is welcomed, thanks!