updateable database 2nd question
| From: | Matt Hedges | Date: | Fri, 20 Jun 2003 18:26:21 +0000 |
| Subject: | updateable database 2nd question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-152339@lists.php.net to get a copy of this message | ||
Thanks for the help. I now have the wine information displaying in text
boxes (below is the code that displays all the wines).
Now I want anyone to be able to change the data in text box/s and hit
"update" and it change that field/s.
Would it be something like
$sql = "UPDATE wines SET
Bodega='$Bodega',Name='$Name',Grape='$Grape',Year='$Year',Region='$Region',S
ubRegion='$SubRegion' WHERE id='$id'"; ?
How do I set it up with the submit, etc?
thanks so much for the help
Matt
<?php
$db = mysql_connect("host", "username", "pw")
or die ("The Database is momentarily down. Sorry for the delay.");
mysql_select_db("username",$db);
$sql = "SELECT * FROM wines ORDER BY Bodega, Name";
$result = mysql_query($sql);
echo "<b><u><font face=verdana>Wines in
Database</font></b></u>:<p>\n";
echo "<table border=1 bgcolor=white valign=top cellspacing=2
cellpadding=2>\n";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr bgcolor=3399cc>\n
<td><input type=text name=Bodega value=\"$Bodega\"></td>\n
<td><input type=text name=Name value=\"$Name\"></td>\n
<td><input type=text name=Grape value=\"$Grape\"></td>\n
<td><input type=text name=Year value=$Year></td>\n
<td><input type=text name=Region value=$Region></td>\n
<td><input type=text name=SubRegion
value=\"$SubRegion\"></td>\n
<td><input type=text name=id value=$id></td>\n
</tr>\n";
}
echo "</table>\n";
?>
--
___________________________
| Matt Hedges
| http://hedgesinnovations.com
|