cturner Posted September 24, 2007 Share Posted September 24, 2007 I am wanting to display buttons with menus to match those buttons. However I have tried this and it isn't working for me. So can someone please have a look at my code that is below and tell if there is a better way of doing this? I know there is a lot of my code but I would appreciate any helpful answer. Thanks in advance. The code for the menus: require "config.php"; // display the javascript menus echo '<script type="text/javascript">'; echo "\n<!--\n"; echo "\nfunction mmLoadMenus() {\n"; // display the menus // get the menu name for each menu $query2 = mysql_query("SELECT menuname, pagetitle FROM menu WHERE menuname != 'Alone' GROUP BY menuname") or die ("Could not query because: ".mysql_error()); while ($row2 = mysql_fetch_array($query2)) { $menuname = $row2['menuname']; // get the menuname, pagetitle, submenu, subid and id number // for the sub menu $query3 = mysql_query("SELECT id, menuname, pagetitle, submenu, subid FROM menu WHERE menuname = '$menuname' GROUP BY menuname") or die ("Could not query because: ".mysql_error()); while ($row3 = mysql_fetch_array($query3)) { $menu_id = "mm_menu_".$row3['id']; $submenu = $row3['submenu']; $menuname = $row3['menuname']; // if submenu = yes if ($row3['submenu'] == 'Yes') { $query5 = mysql_query("SELECT menuname, pagetitle, submenu, subid FROM menu WHERE menuname = '$menuname' GROUP BY submenu") or die ("Could not query because: ".mysql_error()); while ($row5 = mysql_fetch_array($query5)) { $pagetitle = $row5['pagetitle']; $menu_id2 = "mm_menu_".$row5['subid']; echo "if (window.".$menu_id.") return;\n"; // display the page title for sub menu echo "window.".$menu_id2." = new Menu(\"".$pagetitle."\",67,20,\"Verdana, Arial, Helvetica, sans-serif\",10,\"#ffffff\",\"#ffffff\",\"#00397a\",\"#0046c2\",\"left\",\",middle\",3,0,1000,0,0,true,false,true,0,true,true);\n"; // display the sub menu page title echo $menu_id2.".addMenuItem(\"".$row3['pagetitle']."\",\"location='page.php?page=".$row3['pagetitle']."'\");\n"; echo $menu_id2.".hideOnMouseOut=true;\n"; echo $menu_id2.".menuBorder=0;\n"; echo $menu_id2.".menuItemBorder=0;\n"; echo $menu_id2.".menuLiteBgColor='#ffffff';\n"; echo $menu_id2.".menuBorderBgColor='#555555';\n"; echo $menu_id2.".bgColor='#555555';\n"; echo "window.".$menu_id." = new Menu(\"root\",142,20,\"Verdana, Arial, Helvetica, sans-serif\",10,\"#ffffff\",\"#ffffff\",\"#00397a\",\"#0046c2\",\"left\",\"middle\",3,0,1000,-5,7,true,false,true,0,true,true);\n"; echo $menu_id.".addMenuItem(".$menu_id2.",\"location='page.php?page=".$pagetitle."'\");\n"; echo $menu_id.".hideOnMouseOut=true;\n"; echo $menu_id.".childMenuIcon=\"arrows.gif\";\n"; echo $menu_id.".menuItemBorder=0;\n"; echo $menu_id.".menuLiteBgColor='#ffffff';\n"; echo $menu_id.".menuBorderBgColor='#555555';\n"; echo $menu_id.".bgColor='#555555';\n\n"; } } else { // if submenu = no echo "if (window.".$menu_id.") return;\n"; echo "window.".$menu_id." = new Menu(\"root\",142,20,\"Verdana, Arial, Helvetica, sans-serif\",10,\"#ffffff\",\"#ffffff\",\"#00397a\",\"#0046c2\",\"left\",\"middle\",3,0,1000,-5,7,true,false,true,0,true,true);\n"; // get the menu name and page title // for the non sub menu $query4 = mysql_query("SELECT menuname, pagetitle FROM menu WHERE menuname = '$menuname'") or die ("Could not query because: ".mysql_error()); while ($row4 = mysql_fetch_array($query4)) { $add_menu_item = "addMenuItem(\"".$row4['pagetitle']."\",location='page.php?page=".$row4['pagetitle']."')"; echo $menu_id.".".$add_menu_item.";\n"; } echo $menu_id.".hideOnMouseOut=true;\n"; echo $menu_id.".menuBorder=0;\n"; echo $menu_id.".menuItemBorder=0;\n"; echo $menu_id.".menuLiteBgColor='#ffffff';\n"; echo $menu_id.".menuBorderBgColor='#555555';\n"; echo $menu_id.".bgColor='#555555';\n\n"; } } echo $menu_id.".writeMenus();\n\n"; } echo "}\n"; echo "}\n"; echo "//-->\n"; echo '</script>'; The code for the buttons: // buttons go here $query2 = mysql_query("SELECT * FROM pages LEFT JOIN menu ON pages.menuid = menu.id") or die ("Could not query because: " . mysql_error()); while ($row2 = mysql_fetch_array($query2)) { $menuname = $row2['menuname']; if ($menuname != 'Alone') { $pagetitle = str_replace('%20', '', $row3['pagetitle']); echo "<a href=http://www.blueguminteractive.biz/bdgp/admin/page.php?page=".$row3['pagetitle']."><img src=http://www.blueguminteractive.biz/bdgp/admin/images/".$row3['button']."btn.jpeg name=".$pagetitle."btn id=".$pagetitle."btn usemap=#".$pagetitle."btn border=0></a>"; echo "<map name=m_".$pagetitle."_menu id=m_".$pagetitle."_menu><area shape=rect coords=0,0,200,23 href=page.php?page=".$row3['pagetitle'].".php alt=".$pagetitle." onmouseout=MM_startTimeout(); onmouseover=MM_showMenu(window.mm_menu_".$row3['id']."_0,200,0,null,'".$pagetitle."_menu'); /></map>"; } else { echo "<a href=http://www.blueguminteractive.biz/bdgp/admin/page.php?page=".$row3['pagetitle']."><img src=http://www.blueguminteractive.biz/bdgp/admin/images/".$row3['button']."btn.jpeg border=0></a>"; } } // the resources button echo "<a href=\"resources.php\"><img src=\"http://www.blueguminteractive.biz/bdgp/admin/images/resourcesbtn.jpeg\" border=\"0\"></a>"; // the member's login button echo "<a href=\"memberslogin.php\"><img src=\"http://www.blueguminteractive.biz/bdgp/admin/images/membersloginbtn.jpeg\" border=\"0\"></a>"; // add a page button echo "<a href=\"add_page.php\"><img src=\"http://www.blueguminteractive.biz/bdgp/admin/images/addapagebtn.jpeg\" border=\"0\"></a>"; // display the hotspot for the buttons $query4 = mysql_query("SELECT * FROM menu WHERE menuname != 'Alone' GROUP BY pagetitle") or die ("Could not query because: ".mysql_error()); while ($row4 = mysql_fetch_array($query4)) { $pagetitle = str_replace(' ', '', $row4['pagetitle']); if ($row4['submenu'] == 'No') { echo "<map name=m_".$pagetitle."_menu id=m_".$pagetitle."_menu><area shape=rect coords=0,0,200,23 href=page.php?page=".$row4['pagetitle'].".php alt=".$pagetitle." onmouseout=MM_startTimeout(); onmouseover=MM_showMenu(window.mm_menu_".$row4['id']."_0,200,0,null,'".$pagetitle."_menu'); /></map>"; } else { echo "<map name=m_".$pagetitle."_menu id=m_".$pagetitle."_menu><area shape=rect coords=0,0,200,23 href=page.php?page=".$row4['pagetitle'].".php alt=".$pagetitle." onmouseout=MM_startTimeout(); onmouseover=MM_showMenu(window.mm_menu_".$row4['subid']."_0,200,0,null,'".$pagetitle."_menu'); /></map>"; } } mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/70412-menus-arent-displaying/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.