6 Replies - 5408 Views - Last Post: 09 August 2010 - 01:01 PM Rate Topic: -----

#1 torofan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 01-December 09

Popup window to display the PHP variable

Posted 05 August 2010 - 03:21 PM

I have a textarea that is populated with the variable $COPYLTRS, a CLOB, this is done. I am now trying to create a popup window that will display that variable by itself for easier readability. I have created the popup window;
&nbsp;<a href="XXXX/judicial/jo_letters.php?<?php echo '$COPYLTRS'; ?>" target="Popup" onclick="popup(300,300,1)">View Full</a>


However, I can not seem to get the PHP variable, $COPYLTRS, to display in the popup.


Here is my popup page;
	<script language="javascript">
		function closefn(){
			self.close();
		}
	</script>
</head>
<body>
<?php
	$tarea = $_GET['letters'];
	echo $tarea;
?>

	<input type="submit" name="Submit" id="button" value="Submit" onclick="closefn();"/>
</body>



I am not sure where else to go. This is my first time doing this, please help me. Thanks in advance!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Popup window to display the PHP variable

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4334
  • View blog
  • Posts: 12,128
  • Joined: 18-April 07

Re: Popup window to display the PHP variable

Posted 05 August 2010 - 08:01 PM

You are missing the variable name in the URL...

<a href="XXXX/judicial/jo_letters.php?letters=<?php echo '$COPYLTRS'; ?>" target="Popup" onclick="popup(300,300,1)">View Full</a>



Notice in the line above we have added "letters=" to the URL. letters is the variable name that will be used as the key name in $_GET and $COPYLTRS will be its value.

So give that a try and see if it works out for you. :)

P.S. Keep in mind that browsers have a limit on how much data can be sent through a URL. To get around this, instead of passing the data to the popup window, create the popup window and have it fetch the necessary data itself. You can tell the window which record ID (by passing the record ID through the URL) to lookup and fetch the letters from it.

This post has been edited by Martyr2: 05 August 2010 - 08:01 PM

Was This Post Helpful? 1
  • +
  • -

#3 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2990
  • Posts: 10,330
  • Joined: 08-August 08

Re: Popup window to display the PHP variable

Posted 06 August 2010 - 06:08 AM

echo '$COPYLTRS' will output the text: $COPYLTRS. You want to output the value of the variable, so either don't use quotes at all or use double quotes.

<?php
$COPYLTRS = 'some value';
echo '$COPYLTRS'."<br>$COPYLTRS";
?>

Was This Post Helpful? 0
  • +
  • -

#4 batesy3k  Icon User is offline

  • D.I.C Regular

Reputation: 41
  • View blog
  • Posts: 299
  • Joined: 10-September 09

Re: Popup window to display the PHP variable

Posted 06 August 2010 - 08:22 AM

@CTphpnwb Hi, I don't intend to hijack this thread, but why echoing with single quotes does it not output the value of the variable contained, but double quotes do? I know double quotes are string literals...
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

Re: Popup window to display the PHP variable

Posted 06 August 2010 - 08:35 AM

That's the way PHP works. If a variable is enclosed in single quotes there is no translation of PHP variables contained therein. See the PHP manual for more info on this.
Was This Post Helpful? 0
  • +
  • -

#6 torofan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 01-December 09

Re: Popup window to display the PHP variable

Posted 09 August 2010 - 11:07 AM

Thank you Martyr2 for your comment. However I added "letters=" to the a href and now $COPYLTRS is the only work that displays in the window. I have decided to go with the latter idea. Thank you again for the suggestion and your time.

Torofan


View PostMartyr2, on 05 August 2010 - 07:01 PM, said:

You are missing the variable name in the URL...

<a href="XXXX/judicial/jo_letters.php?letters=<?php echo '$COPYLTRS'; ?>" target="Popup" onclick="popup(300,300,1)">View Full</a>



Notice in the line above we have added "letters=" to the URL. letters is the variable name that will be used as the key name in $_GET and $COPYLTRS will be its value.

So give that a try and see if it works out for you. :)

P.S. Keep in mind that browsers have a limit on how much data can be sent through a URL. To get around this, instead of passing the data to the popup window, create the popup window and have it fetch the necessary data itself. You can tell the window which record ID (by passing the record ID through the URL) to lookup and fetch the letters from it.

Was This Post Helpful? 0
  • +
  • -

#7 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: Popup window to display the PHP variable

Posted 09 August 2010 - 01:01 PM

View PostJackOfAllTrades, on 06 August 2010 - 11:35 AM, said:

That's the way PHP works. If a variable is enclosed in single quotes there is no translation of PHP variables contained therein. See the PHP manual for more info on this.


It's also worth noting that newlines (\n), tab characters (t), and other special characters are not parsed in single-quoted strings (just in case someone doesn't follow Jack's very handy link).

This post has been edited by Valek: 09 August 2010 - 01:03 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1