Home > Article > Backend Development > php+mysql method to delete employee information with a specified number, mysql number_PHP tutorial
The example in this article describes the method of deleting employee information with a specified number using php+mysql. Share it with everyone for your reference. The specific analysis is as follows:
Use php to submit the employee number to mysql, and then mysql accepts the data and uses delete to delete the data. Here are some specific examples to share with you.
Example of delete statement:
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 the where clause is not specified, delete will delete all the items in the table. The record will be deleted immediately.
1. Delete the employee information with the specified number, the code is as follows:
".($k)." | ".$v['name']." | ".$ v['age']." |
Key technology: The key point of this example is the flexible use of while() loop statements. According to the submitted parameter values, the while() loop statement is executed, the deletion operation is performed in the loop body, and the loop deletion operation of the data is completed.
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 encoding format of the page. Then, define the loop variables $a and $b, and change the first layer The loop condition in the while loop is set to $b<$a, and then the while statement is used again to loop out the data in the data table and perform the data deletion operation. The code is as follows:
I hope this article will be helpful to everyone’s php+mysql program design.