Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display php on same page it is being requested

Status
Not open for further replies.

bobrivers2003

Technical User
Oct 28, 2005
96
GB
I am tyring to create a page that contains a buttin and when clicked call some php script and displays the results underneath the button on the same page. The php creates a table. I want the table to appear when the button is clicked not when the page is loaded.

Any ideas or pointers?

<input type="submit" value="Enter">
<div style="overflow: auto; width: 700px; height: 200; border-left: 1px gray solid; border-bottom: 1px gray solid;

padding:0px; margin: 0px\">
<table class="sortable" id="unique"width=500>
<tr><th>header1</th><th>header2</th></tr>
<?php

exec('ls' , $output, $return );


foreach ( $output as $line)
{

echo "<tr class=\"line\"><td class=\"line\">";
echo $line;
echo "</td><td class=\"line\"><input type=checkbox name=\"array[]\" value=".$line.">".$line."</td>";
echo "</td></tr>";
}

?>

</table>

Thanks in advance
 
Just add an IF statement that checks wether the button was clicked.

say your button is as follows:
Code:
<input type=submit name=pressed>
Then you would check for it being pressed as:
Code:
If(isset($_POST('pressed'))
{
echo "whatever it is you want to show"
}

else
{
display the form.
echo "<form action=button.php method=POST>...";
}

}

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top