homepage Welcome to WebmasterWorld Guest from 54.234.2.88
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Returning db query results to the form of origin?
can this be done in PHP?
otto_man




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

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?

 

Matt_James




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

<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()

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

coopster




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

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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved