Phpmysq data Edit update instance _ PHP Tutorial

Source: Internet
Author: User
Phpmysq data editing and updating instances. Phpmysq data editing and updating instance * This article is also an entry-level php Tutorial, mainly to show you how to use phpmysq data editing and updating. Php Tutorial mysq data Edit update instance php mysq data Edit update instance/* This article is also an entry-level php Tutorial, mainly to tell you how to use php mysq data to edit updates.

Php Tutorial mysq data Edit update instance
/*
This article is also an entry-level php Tutorial, mainly to show you how to use php mysq data to edit updates.
*/

$ 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; otherwise, the record is modified.
If ($ id ){
$ SQL = "update employees set first = '$ first', last = '$ LA', address =' $ address ', position = '$ position' where id = $ id ";
}
Else {
$ SQL = "insert into employees (first, last, address, position) values ('$ first', '$ LA',' $ address ',' $ position ')";
}
// Issue an SQL command 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 pressed the submit button, execute the following programs.
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 n ",
$ Php_self, $ myrow ["id"], $ myrow ["first"], $ myrow ["last"]);
Printf ("(delete)
", $ Php_self, $ myrow [" id "]);
}
}
?>
"> Return

}
?>

Http://www.bkjia.com/PHPjc/630808.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630808.htmlTechArticlephp mysq data editing update instance/* This article is also an entry-level php Tutorial, mainly to tell you how to use php mysq data editing update Oh. Php Tutorial mysq data Edit update instance...

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.