Passing variables between html forms and updating sql table
| From: | David | Date: | Wed, 17 Sep 2003 14:34:51 +0000 |
| Subject: | Passing variables between html forms and updating sql table | ||
| Groups: | php.db php.db | ||
| Request: | Send a blank email to php-db+get-30552@lists.php.net to get a copy of this message | ||
Dear all
I am putting together some pages where I will be able to update mysql
database using php pages. I am having a problem with updating. I put a
record into textboxes and when I press submit it passes the values to the
next page. The problem I am having is updating the values. Here is my
attempt
<?php
$MySQLLink = mysql_pconnect ("davecp4", "root", "")
or die("Could not attach to database. Please try later or contact
webmaster@anagram-sys.co.uk");
mysql_select_db($database_name, $MySQLLink) or die("ERROR--CAN'T CONNECT
TO DB");
$result = mysql_query("SELECT * FROM ".$table_name) or die("Error: " .
mysql_error());
for($i = 1; $i < mysql_num_fields($result); $i++)
{
$fieldname = mysql_field_name($result, $i);
$fieldname2 = "$".$fieldname;
mysql_query("UPDATE $table_name SET $fieldname=$fieldname2 WHERE id
=$id");
echo $fieldname."<br>".$fieldname2."<br>";
}
?>
--
Kind Regards
David
Anagram Systems
http://www.anagram-sys.co.uk/
http://www.web-planets.com/davec/techsitedb/