Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:30

php and MySQL from database...almost working!!!! help!


Poster: Talloula
Dated: Monday July 22 2002 - 8:01:49 BST

Hello,
I got the menu to work by reading URLs from a MySQL database and dynamically creating the menu.
for the top level menu (no submenus) it works great!

when i created the second level, the submenus are created properly, or so it seems, but it is not displaying them..

here is a copy/paste from the page's source after i preview in browser:

Code:
</head>
<body>


<SCRIPT language=JavaScript type=text/javascript>
/*
Milonic DHTML Website Navigation Menu - Version 3.4
Written by Andy Woolley - Copyright 2002 (c) Milonic Solutions Limited. All Rights Reserved.
Please visit http://www.milonic.co.uk/menu or e-mail menu3 __at__ milonic.com for more information.

The Free use of this menu is only available to Non-Profit, Educational & Personal web sites.
Commercial and Corporate licenses  are available for use on all other web sites & Intranets.
All Copyright notices MUST remain in place at ALL times and, please keep us informed of your
intentions to use the menu and send us your URL.
*/


//The following line is critical for menu operation, and MUST APPEAR ONLY ONCE. If you have more than one menu_array.js file rem out this line in subsequent files
menunum=0;menus=new Array();_d=document;function addmenu(){menunum++;menus[menunum]=menu;}function dumpmenus(){mt="<script language=javascript>";for(a=1;a<menus.length;a++){mt+=" menu"+a+"=menus["+a+"];"}mt+="<\/script>";_d.write(mt)}
//Please leave the above line intact. The above also needs to be enabled if it not already enabled unless this file is part of a multi pack.



////////////////////////////////////
// Editable properties START here //
////////////////////////////////////

// Special effect string for IE5.5 or above please visit http://www.milonic.co.uk/menu/filters_sample.php for more filters
if(navigator.appVersion.indexOf("MSIE 6.0")>0)
{
   effect = "Fade(duration=0.2);Alpha(style=0,opacity=88);Shadow(color='#777777', Direction=135, Strength=5)"
}
else
{
   effect = "Shadow(color='#777777', Direction=135, Strength=5)" // Stop IE5.5 bug when using more than one filter
}


timegap=500         // The time delay for menus to remain visible
followspeed=5      // Follow Scrolling speed
followrate=40      // Follow Scrolling Rate
suboffset_top=10;   // Sub menu offset Top position
suboffset_left=10;   // Sub menu offset Left position

style1=[         // style1 is an array of properties. You can have as many property arrays as you need. This means that menus can have their own style.
"navy",            // Mouse Off Font Color
"ccccff",         // Mouse Off Background Color
"ffebdc",         // Mouse On Font Color
"4b0082",         // Mouse On Background Color
"000000",         // Menu Border Color
12,               // Font Size in pixels
"normal",         // Font Style (italic or normal)
"bold",            // Font Weight (bold or normal)
"Verdana, Arial",   // Font Name
4,               // Menu Item Padding
"",      // Sub Menu Image (Leave this blank if not needed)
,               // 3D Border & Separator bar
"66ffff",         // 3D High Color
"000099",         // 3D Low Color
"Purple",         // Current Page Item Font Color (leave this blank to disable)
"pink",            // Current Page Item Background Color (leave this blank to disable)
"",      // Top Bar image (Leave this blank to disable)
"ffffff",         // Menu Header Font Color (Leave blank if headers are not needed)
"000099",         // Menu Header Background Color (Leave blank if headers are not needed)
"navy",         // Menu Item Separator Color
]

addmenu(menu=["mainmenu",210,20,,1,,style1,1,"left",,,0,,,,,,,,,,,".Home Page","",,"",1,"Games ->","show-menu=17",,"",1,".Forum","show-menu=17",,"",1,"Movies ->","show-menu=15",,"",1,".Family Pics","show-menu=15",,"",1,"My Pictures ->","show-menu=3",,"",1,".phpMovieLib Demo","show-menu=3",,"",1,".phpwsMaps Demo","show-menu=3",,"",1,".News","show-menu=3",,"",1,".Web Links","show-menu=3",,"",1,".Top 10 Stats","show-menu=3",,"",1,".Site Map","show-menu=3",,"",1,".Submit News","show-menu=3",,"",1,".Your Account","show-menu=3",,"",1,".Mp3 Music","show-menu=3",,"",1,".Download Files","show-menu=3",,"",1])

addmenu(menu=["17",,,140,1,"",style1,,"",effect,,,,,,,,,,,,,"Hangman", "mod.php?mod=userpage&amp;menu=1700&amp;page_id=16",,,1,"Asteroids", "mod.php?mod=userpage&amp;menu=1701&amp;page_id=22",,,1,"Solitaire", "mod.php?mod=userpage&amp;menu=1702&amp;page_id=18",,,1,"Rubik Cube", "mod.php?mod=userpage&amp;menu=1703&amp;page_id=25",,,1,"PingPong", "mod.php?mod=userpage&amp;menu=1704&amp;page_id=26",,,1,"Kill Kenny", "mod.php?mod=userpage&amp;menu=1705&amp;page_id=27",,,1,"Space Shooter", "mod.php?mod=userpage&amp;menu=1706&amp;page_id=28",,,1])

addmenu(menu=["15",,,140,1,"",style1,,"",effect,,,,,,,,,,,,,"Add New", "mod.php?mod=phpmovielib&op=addnew",,,1,"Search", "mod.php?mod=phpmovielib&op=displaysearch",,,1,"View All", "mod.php?mod=phpmovielib",,,1])

addmenu(menu=["3",,,140,1,"",style1,,"",effect,,,,,,,,,,,,,"Vail 2002", "mod.php?mod=userpage&amp;menu=314&amp;page_id=19",,,1,"My new Z71", "mod.php?mod=userpage&amp;menu=315&amp;page_id=20",,,1,"Vegas '01", "mod.php?mod=userpage&amp;menu=306&amp;page_id=9",,,1,"MardiGras '01", "mod.php?mod=userpage&amp;menu=310&amp;page_id=13",,,1,"NASA '01", "mod.php?mod=userpage&amp;menu=311&amp;page_id=14",,,1,"Galveston '99", "mod.php?mod=userpage&amp;menu=305&amp;page_id=8",,,1,"Friends '96", "mod.php?mod=userpage&amp;menu=301&amp;page_id=5",,,1,"Picnic '95", "mod.php?mod=userpage&amp;menu=302&amp;page_id=4",,,1,"Cedars '94", "mod.php?mod=userpage&amp;menu=303&amp;page_id=6",,,1,"Scenery 1", "mod.php?mod=userpage&amp;menu=304&amp;page_id=7",,,1,"Babypics 1", "mod.php?mod=userpage&amp;menu=307&amp;page_id=10",,,1,"Babypics 2", "mod.php?mod=userpage&amp;menu=308&amp;page_id=11",,,1,"Painting", "mod.php?mod=userpage&amp;menu=309&amp;page_id=12",,,1,"Driving", "mod.php?mod=userpage&amp;menu=313&amp;page_id=17",,,1])

dumpmenus()
</SCRIPT>
<SCRIPT language=JavaScript type=text/javascript>
/*
Milonic DHTML Website Navigation Menu - Version 3.4.12
Written by Andy Woolley - Copyright 2002 (c) Milonic Solutions Limited. All Rights Reserved.
Please visit http://www.milonic.co.uk/menu or e-mail menu3 __at__ milonic.com for more information.

The Free use of this menu is only available to Non-Profit, Educational & Personal web sites.
Commercial and Corporate licenses  are available for use on all other web sites & Intranets.
All Copyright notices MUST remain in place at ALL times and, please keep us informed of your
intentions to use the menu and send us your URL.
*/
Mtimer=setTimeout("rep_img()",99999);_d=document;smc=-1;MLoaded=0;ST=0;mspu=0;pu=0;
ns4=(_d.layers)?true:false
......etc...



the problem is, I see the main menu, but when i place the mouse over one of the items, the submenus are not appearing!
any suggestions are highly appreciated!


Poster: Andy
Dated: Monday July 22 2002 - 9:28:00 BST

You array file syntax is correct and the sub menus are appearing correctly. However, you are duplicating the calls for the sub-menus.

You've got 2 calls for menu17, 2 for 15 and 11 for menu3. If you actually create all the menus as you want them you will be able the see the menu work correctly.

Cheers
Andy


Poster: Talloula
Dated: Monday July 22 2002 - 9:42:01 BST

so having more than one entry call the same submenu will create a problem?

i knew that i had duplicates...and i need to fix the script (it's a recursive algorithm) but i first thought i'd look for more obvious problems, since logically, the duplicates would just display the same submenu...or so i assumed!

thanks
Talloula


Poster: Andy
Dated: Monday July 22 2002 - 9:59:43 BST

The menu does display the same menu but the highlight will not work correctly thus indicating a problem with the script.

Duplicating menus is usually undesired your script is working though.

Cheers
Andy.

echoing from php is tricky!!!


Poster: Talloula
Dated: Monday July 22 2002 - 10:35:37 BST

I realized that if I add or remove one line break, it changes everything!

echo "\n"; <---

so now i'm going to re-do the whole thing more carefully, because I wasn't paying much attention to the empty spaces and new line breaks, I am not familiar with javascript and i assumed the compiler ignores empty spaces! apparently it doesn't!

back to square one


Poster: Andy
Dated: Monday July 22 2002 - 14:02:56 BST

I have a MySQL data structure and a PHP Script to produce a menu from a Table.

Would you like to try and see if you can get it to work on your machine?

-- Andy


Poster: Talloula
Dated: Monday July 22 2002 - 14:05:57 BST

that would be awesome, please email it to me my address is talal at mi4.com
thanks in advance
Talal