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...