Hello,
Sorry to ask what is probably a simple answer, but I am having problems
updating a table/database from a PHP/
PHTML file. I can Read From the Table, I can Insert into Table/Database, But
not update. Here is a copy of the
script I am using. I do not know what version of MySQL my host is running
nor do I have Shell Access to it. I
would like to setup a script so my website users can update thier records
without my intervention. Thank You In
Advance.
Also you may send replies to st**********@yahoo.com
Begin Script
<?php
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("databasename",$db);
if ($id) {
if ($submit) {
$sql = "UPDATE tablename SET
EMail='$EMail',Username='$Username',Password='$Pas sword',Item=
'$Item',Price='$Price',URL='$URL' WHERE Username='$Username'";
$result = mysql_query($sql);
echo "table Updated.";
} else {
// query the DB
$sql = "SELECT * FROM tablename WHERE Username='$Username'";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
e-Mail Address:<input type="Text" name="EMail" value="<?php echo
$myrow["EMail"] ?>"><br>
Username:<input type="Text" name="Username" value="<?php echo
$myrow["Username"] ?>"><br>
Password:<input type="Text" name="Password" value="<?php echo
$myrow["Password"] ?>"><br>
Item:<input type="Text" name="Item" value="<?php echo $myrow["Item"]
?>"><br>
Price:<input type="Text" name="Price" value="<?php echo $myrow["Price"]
?>"><br>
Item URL:<input type="Text" name="URL" value="<?php echo $myrow["URL"]
?>"><br>
<input type="Submit" name="Update" value="Update table">
</form>
<?php
}
} else {
// display list of articles
$result = mysql_query("SELECT * FROM tablename",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?Username=%s\">%s %s</a><br>\n", $PHP_SELF,
$myrow["Username"], $myrow["Item"], $myrow
["URL"]);
}
}
// Close DB Connection
mysql_close()
?>
End Script