I am trying to display javascript menus using php. Most of my code displays as javascript code however displaying the right page links for each menu, isn't working for me. For example the javascript code should look like this: mm_menu_1.addMenuItem("BDGP BOARD","location='page.php?page=BDGP+Board'");. So can someone please have a look at my code and tell how I can achieve the above? Thanks in advance.

Here is my code:
Code PHP:
$query = mysql_query("SELECT menuname, pagetitle, menuid FROM menu LEFT JOIN pages ON menu.menuname = pages.menuid") or die ("Could not query because: ".mysql_error());
 
echo '<script type="text/javascript">';
echo "\nfunction mmLoadMenus() {\n";
while($row=mysql_fetch_assoc($query)) {
 
$add_menu_item = "addMenuItem(".$row['pagetitle'].",location=page.php?page=".$row['pagetitle'].")";
$menu_id = "mm_menu_".$row['menuid'];
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";
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 '</script>';