View Full Version : Passing PHP variables to AnyLink Menu v2.2

01-27-2011, 12:00 AM
1) Script Title: AnyLink Drop Down Menu 2.2

2) Script URL (on DD): DD AnyLink Drop Down Menu 2.2 (http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm) Using the Vertical Menu on EU click.

3) Describe problem: I found this amazing menu, works perfect with what I'm trying to accomplish on my site. I'm doing a lot of heavy PHP & MySQL db work, pulling variables into each page... It's a very dynamic site... My problem is I have no clue how to pass a variable that I've pulled from MySQL Query to the actual menu.

I tried adding
var member = "<?=$member?>" within the script added in the heading, but that didn't work. Then as well in the menucontents.js file, for example:
["Profile", "profile.php?UID="+member] It actually halted the menu from working at all and just made the link, a straight link, instead of popping up the menu. It seems adding the variable in the head doesn't both the script, what's doing it is the '+member' within the menucontents.js file... I've done this before with JS files, I'm not quite sure why this isn't working properly.

A lil more of a description of what I want to do:
The coding is for a display box to display users who are currently logged into my website and each user will have an arrow next to their name, where a user should be able to click on it to get the pop up menu and choose an option, like go to $member's profile, view $member's photos, etc... Each link would be dynamic in the sense that it would pass a variable to the URL (example: profile.php?UID=$member).

Please help! Any help is greatly appreciated! :confused:

01-27-2011, 06:07 AM
var member = "<?php echo $member; ?>";

That assumes the file where you're doing this has the appropriate header, the .php extension, and that $member is already defined.

One tool you may or may not be aware of for diagnosing stuff like this is the browser's 'view source'. It will show you what the server is serving to the browser. So for example, if the above code is done properly, the 'view source' will look something like:

var member = "John Doe";