Home > Article > Backend Development > How to delete employee information with specified number in php mysql_PHP tutorial
This article mainly introduces the method of deleting employee information with specified number in php mysql. It involves mysql database operation skills and has certain reference. Value, friends in need can refer to it
The example in this article describes how to delete 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:
The code is as follows:
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:
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:
The code is as follows:
I hope this article will be helpful to everyone’s php mysql program design.