PHP mysq Data Edit Update Instance/* This article is also an entry-level PHP tutorial, mainly to show you how to use PHP mysq data editing update OH.
PHP Tutorial MYSQ Data Editing Update instance
/*
This article is also an entry-level PHP tutorial, mainly to show you how to use PHP mysq data editing update OH.
*/
$db = MySQL tutorial _connect ("localhost", "phpdb", "phpdb");
mysql_select_db ("Test", $db);
If the submit button is submitted
if ($submit) {
If there is no ID, the record is added, or the record is modified
if ($id) {
$sql = "Update employees set first= ' $first ', last= ' $last ', address= ' $address ', position= ' $position ' where id= $id";
}
else {
$sql = "INSERT INTO employees (first,last,address,position) VALUES (' $first ', ' $last ', ' $address ', ' $position ')";
}
Issuing SQL commands to the database tutorial
$result = mysql_query ($sql);
echo "Record modified successfully!" <> ";
echo "Back";
}
ElseIf ($delete) {
Delete a record
$sql = "Delete from employees where id= $id";
$result = mysql_query ($sql);
echo "Record deleted successfully!" <> ";
echo "Back";
}
else {
If you have not yet pressed the submit button, then perform this part of the program
if (! $id) {
If the status is not modified, the employee list is displayed
$result = mysql_query ("SELECT * FROM Employees", $DB);
while ($myrow = Mysql_fetch_array ($result)) {
printf ("%s%s n",
$php _self, $myrow ["id"], $myrow ["First"], $myrow ["last"]);
printf ("(delete)
", $php _self, $myrow [" id "]);
}
}
?>
"> Return
}
?>
http://www.bkjia.com/PHPjc/630808.html www.bkjia.com true http://www.bkjia.com/PHPjc/630808.html techarticle PHP mysq Data Edit Update Instance/* This article is also an entry-level PHP tutorial, mainly to show you how to use PHP mysq data editing update OH. PHP Tutorial mysq Data Edit Update instance ...