cturner Posted August 30, 2007 Share Posted August 30, 2007 I am wondering if someone could please tell me how I could get the page title for the sub menu? I have been working on this one for hours and am getting nowhere. How can I make my php code display the syntax highlighting? I have forgotten. Thanks in advance. Here is my table: Menu id // autoincrement / primary key menuname pagetitle submenu subid The code that I have already written is suppose to display JavaScript menus. I have got the other menus to display however I am having trouble displaying the submenus. Here is my code: 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>'; mysql_close(); Quote Link to comment https://forums.phpfreaks.com/topic/67356-getting-the-page-title-for-the-sub-menu/ 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.