Troy297
01-31-2007, 07:01 PM
This may seem very newbish to some but I have never tried to use php inside javascript before and am having problems now that I am trying it.....
I have a slide out menu as seen here (http://www.dynamicdrive.com/dynamicindex1/anylinkvertical.htm) and as one of the menu options that pops out I am trying to have it say "View Inbox(#)" and where the # is I use php to count the messages in the mysql database that are for them. So here is my code... how can I do this?
<script type="text/javascript">
//other stuff here
var menu3=new Array()
menu3[0]='<?php
echo "<a href='inbox.php'>";
$result = mysql_query("SELECT COUNT(id) FROM rp_pm WHERE todj='$_SESSION[username]'");
$total = mysql_fetch_array($result);
echo "View Inbox (". $total['COUNT(id)'] .")</a>";
?>'
//other stuff here
</script>
So there is the php code I am trying to use... now I realize that I am not allowed to use any ' inside the php because the menu= uses them... but even when I tried taking them it out didn't work.
Any help would be great! Thanks so much!
I have a slide out menu as seen here (http://www.dynamicdrive.com/dynamicindex1/anylinkvertical.htm) and as one of the menu options that pops out I am trying to have it say "View Inbox(#)" and where the # is I use php to count the messages in the mysql database that are for them. So here is my code... how can I do this?
<script type="text/javascript">
//other stuff here
var menu3=new Array()
menu3[0]='<?php
echo "<a href='inbox.php'>";
$result = mysql_query("SELECT COUNT(id) FROM rp_pm WHERE todj='$_SESSION[username]'");
$total = mysql_fetch_array($result);
echo "View Inbox (". $total['COUNT(id)'] .")</a>";
?>'
//other stuff here
</script>
So there is the php code I am trying to use... now I realize that I am not allowed to use any ' inside the php because the menu= uses them... but even when I tried taking them it out didn't work.
Any help would be great! Thanks so much!