PHP mysq Data Editing update Instance _php tutorial

Source: Internet
Author: User
Tags mysql tutorial
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.