|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dear All,
I have problem with creating a DHTML horizontal menu that is database driven. My Menu is created using 2 javascript file, and I call those 2 files from a PHP file header.php In this header.php, I open up connection and choose database, and then do sql query and get the data using 'for loop', and then I passed the values to javascript using 'input = hidden tag' but then i realized that because the content of the menu is from database, so i dont know exactly how many titles and sub-titles in the menu. The question is how should i construct a for loop in the javascript ? The conditions ? This is how I construct my database: Fields: Id, title*, url, parentId** *This are what is shown in the menu ** ParentId = 0 means it's the main title ParentId = 1 means it's the it's the sub-title for main title 1 This is what I include in the header.php beside the images PHP Code:
And this is how it looks like after I get the values in the javascript: Quote:
Anybody can help me, or can think of a better way to do it ? I really appreciate any help. Thanks, Cezar |
|
#2
|
||||
|
||||
|
I've recently used the exact same menu system and implemented it using ASP.
I write out the menu items directly to the page from the ASP (it looks like your doing something involving hidden fields? Looks like you might be making it harder than necessary) Here's what I did (done server-side): 1. Perform the query to get the menu items 2. Get the number of records so that you can setup the menu array properly. 3. Begin a loop to go thru and write out each menu item (and sub's) 4. Before you perform the writes tho, you need to perform a count on the number of subs. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > PHP, Mysql Database Driven Menu |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|