In PHP, how does one batch delete data in a data table so that data in a data table needs to be deleted in batches? how can I write code!
Reply to discussion (solution)
Delete tbl_name where id in ($ var1, $ var2 ,...)
This is a $ _ POST array. multiple content submitted in a form is transmitted to PHP using $ _ POST,
PHP retrieves $ _ POST and uses foreach to traverse $ _ POST. In this example, DELETE 'DB _ name' WHERE id = ". $ _ POST [] is used.
This is a $ _ POST array. multiple content submitted in a form is transmitted to PHP using $ _ POST,
PHP retrieves $ _ POST and uses foreach to traverse $ _ POST. In this example, DELETE 'DB _ name' WHERE id = ". $ _ POST [] is used.
How to put the ID submitted in FORM in an array...
When you generate the checkbox, you can specify it as an array, and then submit it as an array.
Then you can traverse the deletion or in ()... deletion operations.
$ _ POST is an array.
Every tag is an input, right? Each input has a name value,
After the LZ check box is selected, click submit. $ _ POST ['here is the name value of input '] will be submitted to the PHP page.
If selected, true is not selected, and false is selected.
Use
If ($ _ POST ['input name value']) {
Echo 'I have been selected ';
// Here, write the MYSQL deletion statement.
}
This if statement is set to a while statement.
$ _ POST is an array.
Every tag is an input, right? Each input has a name value,
After the LZ check box is selected, click submit. $ _ POST ['here is the name value of input '] will be submitted to the PHP page.
If selected, true is not selected, and false is selected.
Use
If ($ _ POST ['input name value']) {
Echo 'I have been selected ';
// Here, write the MYSQL deletion statement.
}
This if statement is set to a while statement.
Actually, you don't need a while loop. I did this.
Include (".. /conn. php "); $ array = implode (", ", $ _ POST ['flags']); $ query =" delete from tbl_user where ID in ($ array )"; $ SQL = mysql_query ($ query); if ($ SQL) {echo "script" alert ('deleted successfully'); window. location. href = 'show _ user. php 'script ';} else {echo "script alert ('deletion failed'); window. location. href = 'show _ user. php 'script ';}
Write the text box as follows:
When you post a file, you can get it on the server: $ id = $ _ POST ['id']; select the column and obtain the value of the column.