Submit the employee ID to mysql using php, and then mysql accepts the data and uses delete to delete the data. I will share with you several examples below. example of the delete statement: deletefromfriendsw... submit the employee ID to mysql using php, and then mysql accepts the data and uses delete to delete the data. I will share with you several examples below.
Example of a delete statement:
Delete from friends where user_name = 'simaopig ';
In the syntax structure, we can see that, like the update syntax, we can omit the where clause, but this is a very dangerous behavior, because if you do not specify the where clause, delete deletes all records in the table and deletes them immediately.
1. delete the employee information of the specified number. the code is as follows:
Employee info table
No. |
Name |
Age |
Array ('name' => 'Zhang San', 'age' => 18), '2' => array ('name' => 'Li Si ', 'age' => 19), '3' => array ('name' => 'Wang 5', 'age' => 20); if (! Emptyempty ($ _ POST ['num']) {unset ($ _ SESSION ['arr'] [$ _ POST ['num']); // delete the employee information of the specified id} if (isset ($ _ SESSION ['arr']) {foreach ($ _ SESSION ['arr'] as $ k => $ v) {echo"
". ($ K )." |
". $ V ['name']." |
". $ V ['age']." |
";}}?>
2. example of batch deletion of employee information
Key technology: the key point of this instance is the flexible use of the while () loop statement. execute the while () loop statement based on the submitted parameter value and delete the loop weight, the data is deleted cyclically.
Design process:
(1) create a PHP script file. first, connect to the MySQL database server, connect to the database named db_while in MySQL, and set the page encoding format. then, define the variable variables $ a and $ B, set the condition of the loop in the 1st-layer while loop to $ B <$ a, and then use the while statement to output the data in the data table again, and execute the data deletion operation. the code is as follows:
"; // Output the name of the employee to be deleted // open-source code phprm.com $ B ++ }}}?>
(2) store the file in the MR 2 66 folder and name it index. php.
Permanent address:
Reprint at will ~ Please bring the tutorial URL ^