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

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
Talloula
Advanced
Advanced
Posts: 13
Joined: Sat Jul 20, 2002 7:04 am

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

Post by Talloula »

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: Select all

</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@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&menu=1700&page_id=16",,,1,"Asteroids", "mod.php?mod=userpage&menu=1701&page_id=22",,,1,"Solitaire", "mod.php?mod=userpage&menu=1702&page_id=18",,,1,"Rubik Cube", "mod.php?mod=userpage&menu=1703&page_id=25",,,1,"PingPong", "mod.php?mod=userpage&menu=1704&page_id=26",,,1,"Kill Kenny", "mod.php?mod=userpage&menu=1705&page_id=27",,,1,"Space Shooter", "mod.php?mod=userpage&menu=1706&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&menu=314&page_id=19",,,1,"My new Z71", "mod.php?mod=userpage&menu=315&page_id=20",,,1,"Vegas '01", "mod.php?mod=userpage&menu=306&page_id=9",,,1,"MardiGras '01", "mod.php?mod=userpage&menu=310&page_id=13",,,1,"NASA '01", "mod.php?mod=userpage&menu=311&page_id=14",,,1,"Galveston '99", "mod.php?mod=userpage&menu=305&page_id=8",,,1,"Friends '96", "mod.php?mod=userpage&menu=301&page_id=5",,,1,"Picnic '95", "mod.php?mod=userpage&menu=302&page_id=4",,,1,"Cedars '94", "mod.php?mod=userpage&menu=303&page_id=6",,,1,"Scenery 1", "mod.php?mod=userpage&menu=304&page_id=7",,,1,"Babypics 1", "mod.php?mod=userpage&menu=307&page_id=10",,,1,"Babypics 2", "mod.php?mod=userpage&menu=308&page_id=11",,,1,"Painting", "mod.php?mod=userpage&menu=309&page_id=12",,,1,"Driving", "mod.php?mod=userpage&menu=313&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@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!
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

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
Talloula
Advanced
Advanced
Posts: 13
Joined: Sat Jul 20, 2002 7:04 am

Post by Talloula »

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
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

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.
Talloula
Advanced
Advanced
Posts: 13
Joined: Sat Jul 20, 2002 7:04 am

echoing from php is tricky!!!

Post by Talloula »

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
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

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
Talloula
Advanced
Advanced
Posts: 13
Joined: Sat Jul 20, 2002 7:04 am

Post by Talloula »

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