• 0

Showing PHP output in a layer


Question

Hi all.

I'm having a php script which selects some rows from a database and prints it on the screen (with the echo() command). The problem is that it opens a new window to print the output, while I'd like it to simply show up in a layer on the site.

Any ideas on how to do this?

Link to comment
https://www.neowin.net/forum/topic/477261-showing-php-output-in-a-layer/
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Ok, here is the output part of my PHP script. The code to connect to the database is left out.

echo "<TABLE border='1'>";
  echo "<THEAD><TR><TH>Item</TH><TH>Amount</TH></TR>";
  echo "<TBODY>";

  $i=0;
  while ($i < $num) {

	$itemname=mysql_result($result,$i,"itemname");
	$itemamount=mysql_result($result,$i,"itemamount");

	echo "<TR><TD>$itemname</TD><TD>$itemamount</TD></TR>";

	$i++;
  }

  echo "</TBODY></THEAD></TABLE>";

The html part:

<div id="bankItemsLayer" class="message" style="position:absolute; left:140px; top:265px; width:400px; height:244px; z-index:7">
<form action="listbankitems.php" method="post">
	Click here: 
	<input type="submit" id="click to see the list of items" value="send command">
  </form>
</div>

It's in this div layer that I want the table that is created in the PHP script to show, instead of in a new page. Here's a screenshot that might make things more clear (when you click the button "send command" , the php script is executed):

post-96267-1152472675.gif

  • 0

Wouldn't something like the below work for the PHP:

  $output .= '<TABLE border='1'>';
  $output .= '<THEAD><TR><TH>Item</TH><TH>Amount</TH></TR>';
  $output .= '<TBODY>';

  $i=0;
  while ($i < $num) {

	$itemname=mysql_result($result,$i,"itemname");
	$itemamount=mysql_result($result,$i,"itemamount");

	$output .= '<TR><TD>$itemname</TD><TD>$itemamount</TD></TR>';

	$i++;
  }

  $output .= '</TBODY></THEAD></TABLE>';

return $output;

i would have thought the above works ? :blink:

  • 0
  MiG- said:

Wouldn't something like the below work for the PHP:

  $output .= '<TABLE border='1'>';
  $output .= '<THEAD><TR><TH>Item</TH><TH>Amount</TH></TR>';
  $output .= '<TBODY>';

  $i=0;
  while ($i < $num) {

	$itemname=mysql_result($result,$i,"itemname");
	$itemamount=mysql_result($result,$i,"itemamount");

	$output .= '<TR><TD>$itemname</TD><TD>$itemamount</TD></TR>';

	$i++;
  }

  $output .= '</TBODY></THEAD></TABLE>';

return $output;

i would have thought the above works ? :blink:

Apart from the potential XSS you just created*, that's pointless, return is used inside a function to pass back a variable, so your code is not going to output anything at all. I'm pretty sure the guy just wants ajax.

*$output is never set and is just appending, so with register_globals on i can insert some html, or more importantly javascript, into the page using a crafted url. An example of it's use would be to grab a users cookies for your site from the client end using javascript.

  • 0
  Kudos said:

Apart from the potential XSS you just created*, that's pointless, return is used inside a function to pass back a variable, so your code is not going to output anything at all. I'm pretty sure the guy just wants ajax.

*$output is never set and is just appending, so with register_globals on i can insert some html, or more importantly javascript, into the page using a crafted url. An example of it's use would be to grab a users cookies for your site from the client end using javascript.

i see. :p

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.