PDA

View Full Version : Is there a PHP developer who can spare 5 minutes?



jOEL
September 27th, 2006, 09:48 AM
Greetings...

I typically don't just ask for help without first trying to figure it out - in all honestly I just don't have the time today and I need a quickie solution.

(I have a solution in ColdFusion and it's super simple - I'm assuming it is in PHP as well)

PROBLEM:
I need to link to an HTML page which contains a SWF object and pass that object a parameter.

SOLUTION:
I'll pass the key|value pair on the URL to a PHP page.
Using PHP, parse the value and write that string to the appropriate place in the embedded object
(the swf object's source string)

I attached some simplified source files.
index.html (would be the PHP page?)
any_page.html (would be the page that links to the Flash page and passes query string key|value pair )

Any help would be GREATLY appreciated as I'm running out of time by the hour!
Thank you in advance.

// jOEL

bwh2
September 27th, 2006, 09:57 AM
meh, you're probably going to do something like this:

<?php
$myVars;
foreach( $_GET as $key=>$val ) {
$myVars.= $key.'='.$val.'&';
}
$myVars = substr( $myVars, 0, strlen($myVars)-1 );
?>

<this is your object code ...src="myflashfile.swf?<?php echo $myVars; ?>">
i don't know exactly how flash files accept variables via the url, but i would imagine it's something like this.

jOEL
September 27th, 2006, 10:19 AM
DUDE!
You're awesome!
Thanks a million.

Unless I'm mistakes this will take multiple key|value pairs as well and seperate them with "&" - is that correct?

bwh2
September 27th, 2006, 10:23 AM
yes. so if your URL is http://mysite.com?name=joel&posts=77&avatar=gorilla, the php will output:

<object code... src="myflashfile.swf?name=joel&posts=77&avatar=gorilla">
essentially it will replicate the URL.

jOEL
September 27th, 2006, 10:47 AM
Thanx so much, man!
It was just a matter of time before multiple key value pairs was required.

Again, I really appreciate your help.
Have a great day.

bwh2
September 27th, 2006, 10:49 AM
no problem. good luck with that.