whitepony6767 Posted May 8, 2007 Share Posted May 8, 2007 Here is the code I am trying to make work. However it kills the javascript all together. //Contents for menu 5 var menu5=new Array() <? $linksx=mysql_query("SELECT * FROM links ORDER BY title"); while($links=mysql_fetch_array($linksx)) { $link_title = stripslashes($links['title']); ?> menu5[<?=$links['link_id']?>]='<a href="<?=$links['link']?>"><?=$link_title?></a> <? } ?> Here is how the hardcoded menu 2 looks. //Contents for menu 2 var menu2=new Array() menu2[0]='<a href="?page=agentprofiles">Panic Agents</a>' menu2[1]='<a href="?page=newprofile">New Agent Profile</a>' menu2[2]='<a href="?page=editprofile">Edit Agent Profile</a>' any insite you could give me would be very useful. Quote Link to comment Share on other sites More sharing options...
poofacer Posted May 9, 2007 Share Posted May 9, 2007 yea im new to javascript and i tried something similar, even a very simple php code inside of the script tags and the entire javascript disappears. I dont think this can be done like this. maybe this would work. <script language='javascript'> var menu5=new Array() </script> <? $linksx=mysql_query("SELECT * FROM links ORDER BY title"); while($links=mysql_fetch_array($linksx)) { $link_title = stripslashes($links['title']); ?> <script language="javascript" >menu5[</script> <?=$links['link_id']?><script language="javascript" >]='<a href="</script> <?=$links['link']?><script language="javascript> "></script> <?=$link_title?>[/url] <? } ?> so basically keep php and javascript as two different entities execute outside of one another. so probably you have to manipulate like that. check it out. Quote Link to comment Share on other sites More sharing options...
nogray Posted May 9, 2007 Share Posted May 9, 2007 The php shouldn't give you any issue with the Javascript since it's processed in the server (the browser sees the output only). Run the script and view the source, make sure the output of your script is correct. For example, do you close your single quote after you close your anchor tag? You can post the output here if you need anymore help. please use [ code ] for your code. Quote Link to comment 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.