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 stevennyoung@ya hoo.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='$User name',Password= '$Password',Ite m=
'$Item',Price=' $Price',URL='$U RL' WHERE Username='$User name'";
$result = mysql_query($sq l);
echo "table Updated.";
} else {
// query the DB
$sql = "SELECT * FROM tablename WHERE Username='$User name'";
$result = mysql_query($sq l);
$myrow = mysql_fetch_arr ay($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("SE LECT * FROM tablename",$db) ;
while ($myrow = mysql_fetch_arr ay($result)) {
printf("<a href=\"%s?Usern ame=%s\">%s %s</a><br>\n", $PHP_SELF,
$myrow["Username"], $myrow["Item"], $myrow
["URL"]);
}
}
// Close DB Connection
mysql_close()
?>
End Script
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 stevennyoung@ya hoo.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='$User name',Password= '$Password',Ite m=
'$Item',Price=' $Price',URL='$U RL' WHERE Username='$User name'";
$result = mysql_query($sq l);
echo "table Updated.";
} else {
// query the DB
$sql = "SELECT * FROM tablename WHERE Username='$User name'";
$result = mysql_query($sq l);
$myrow = mysql_fetch_arr ay($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("SE LECT * FROM tablename",$db) ;
while ($myrow = mysql_fetch_arr ay($result)) {
printf("<a href=\"%s?Usern ame=%s\">%s %s</a><br>\n", $PHP_SELF,
$myrow["Username"], $myrow["Item"], $myrow
["URL"]);
}
}
// Close DB Connection
mysql_close()
?>
End Script
Comment