Skip to main content
Inspiring
March 20, 2012
Answered

Send PHP/MySQL results to popup window as HTML

  • March 20, 2012
  • 1 reply
  • 2403 views

Hi all,

Not even sure if this can be done, but I have a Results.php page that includes a line:

"My task,  [<?php echo $row_Recordset1['Task'];?>], is in the top [<?php echo $row_Recordset1['RankPercent']; ?>] of tasks in the company";

...where the php tags represent results from a MySQL search.

How do I send this as html to a mini-popup window so that the people can send it to their friends on facebook/twitter/etc?

NOTE: the issue here isn't in creating a popup page - I can do this.

What I need to be able to do is pass that sentence to the popup.php page "exactly" as it appears on the page when rendered.

I have been experimenting down the...

$text = "My task, [<?php echo $row_Recordset1['Task'];?>], is in the top [<?php echo $row_Recordset1['RankPercent']; ?>] of tasks in the company";

...route, but this just gives a load of parse errors (predicably enough).

Any thoughts?

This topic has been closed for replies.
Correct answer

You can use curly brackets to include the recordset values directly:

$text = "My task, [{$row_Recordset1['Task']}], is in the top [{$row_Recordset1['RankPercent']}] of tasks in the company";

1 reply

Participating Frequently
March 20, 2012

I don't know php, but in most other languages variables should not appear within double quotes, otherwise they are interpreted as literal. So maybe:

$text = "My task, [" . <?php echo $row_Recordset1['Task'];?>  . "], is in the top [" . <?php echo $row_Recordset1['RankPercent']; ?> . "] of tasks in the company";

_AJD_TUS_Author
Inspiring
March 20, 2012

Actually, that's pretty good! There is a slight syntax error - the first <?php doesn't seem to render properly (in fact, the second one looks good until you take the first one out, and then it develops the same problem as the first one did...). Any cloues?

If not, don't worry - I'm sure I can debug it from here, but if you can think of anything I'd love to hear it. It seems to be something to do with the double quotes...

Correct answer
March 21, 2012

You can use curly brackets to include the recordset values directly:

$text = "My task, [{$row_Recordset1['Task']}], is in the top [{$row_Recordset1['RankPercent']}] of tasks in the company";