Do you know how to store multi-level menus in db and build them into html lists using php?
p.s.: i googled and could not find what i need
I don't know if you will find this all packaged together. CMS's generally have dynamic menus and individual templates may have multi-level drop-down's built on top of that. If you do a search, you will find many JQuery drop-down menu solutions. If you do a search, you can also find articles about building dynamic menus. This is one example.
You can use a few different patterns. The most popular would be the parent_id field, where top level items have a parent_id of 0, all sub items have a parent_id equal to the id of their parent:
id | label | url | pos | parent_id
I recently gave an answer for this. Search DW. However, I think it was for just one sublevel. Multiple levels will require something else possibly.
Thank you, chrishea. Well, I'm interested not in JS, but in PHP + MySQL implementation. How to store and how to build it - that's what I want to know. Actually I have one idea:
Store the items in table with below structure:
| category_id | parent_category_id | category_name |
, and build from this table the html ul li lists recursively or using two or three loops. However, it's gonna do it everytime page is loaded, so is it practically good solution?
Isn't it better to make fixed menu (because I'm writing site for myself, not CMS)?
But anyway I want to learn how professionals would make php+mysql dynamic menu :)
Thanks, ardav. So what is the best php solution of building nested list from the table you suggested?
`.model small .stack 100 .data kernel DB 10 DUP(1) input DB 1, 2, 3, 4, 5, 6, 7 output DB 0, 0, 0, 0, 0, 0, 0 .code MAIN PROC ...
<!doctype html> <html lang="en-US"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Empathy</title> <link href="template.css" rel="stylesheet" type="text/css"> </head> <body> <div class="container"> <header> <a href=""> <h4 class="logo"> <img src="page-1_2.png" ...
So I have website listing characters from a multi person RP I take part in
the site uses bootstrap as well as a mysql database. I have a working search ...