Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Returning db query results to the form of origin?

can this be done in PHP?



9:58 am on Jul 31, 2003 (gmt 0)

10+ Year Member

I would like to submit a database query from a form and have the data returned to that same form and displayed in the appropriate text fields, select boxes, etc. Is this possible using PHP?


1:22 pm on Jul 31, 2003 (gmt 0)

10+ Year Member

<input name="text" type="text" value="<? echo$var;?>">
would do text fields

This code would select day 4 in a select field of 1-31 days,
having used getdate()

while($day <32){
if($aday==$day){ $select=" selected"; }
echo"<OPTION value=\"$day\" ".$select.">".$day."</OPTION>\n";


3:48 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You sure can. It's quite a common practice:

if ($_POST['submitbutton']) {
your processing statements here;
#display the form again:
<form method="post" action="<?php print $_SERVER['PHP_SELF'];?>">
$rows = mysql_query("SELECT * FROM tablename");
while ($row=mysql_fetch_array($rows)) {
print "<input type=\"text\" name=\"name\" value=\"$row['value']" />

Featured Threads

Hot Threads This Week

Hot Threads This Month