Jump to content

Passing php variable through URL


fraser5002

Recommended Posts

Hi this is probably a easy question but i have been rattling my mind to it for about half an hour now .  Im using an onclick event of a button to open a new webpage passing a PHP variable through the url

 

at the moment im trying to use the following code.

 

onclick="window.open('otherwebpage.php?itemtopassinurl=<? echo "$title[$i]"; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')" ?>'

 

I know i cant use the " " in the php bit of the code but i dont know what to use instead .  I assume i cant use the ' character either???

 

How can i do this?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/241083-passing-php-variable-through-url/
Share on other sites

Original:

onclick="window.open('otherwebpage.php?itemtopassinurl=<? echo "$title[$i]"; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')" ?>'

 

Revised:

onclick="window.open('otherwebpage.php?itemtopassinurl=<?php echo $title[$i]; ?>','popuppage','width=300,toolbar=1,resizable=0,scrollbars=yes,height=700,top=100,left=100')"

 

 

its worth noting that use of <? the shortcode version shouldn't be used in general as its a depreciated method that I believe come PHP v6 will be removed all together.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.