How to bulk delete data from a data table in PHP

Source: Internet
Author: User
Tags mysql delete
In this way, we need to delete data from the data table in bulk, how to write the code ... Ask Daniel to guide the maze!


Reply to discussion (solution)

Delete tbl_name where ID in ($var 1, $var 2,...)

This is a $_post array, which submits multiple content in a form with $_post[] to PHP,
PHP gets $_post, with a foreach traversal of $_post, with "DELETE ' db_name ' WHERE id =". $_post[]

This is a $_post array, which submits multiple content in a form with $_post[] to PHP,
PHP gets $_post, with a foreach traversal of $_post, with "DELETE ' db_name ' WHERE id =". $_post[]
How to put the ID submitted in the form in an array ...

When you generate a checkbox, you can specify an array, and then commit it once.
Then traverse Delete or in () ... Delete all can

$_post itself is an array.
Every tag is a single input, right? Each of the input has a name value,
LZ after the check click Submit (Submit), $_post[' This is the name value of input '] will be submitted to the PHP page.
If you select it, True is not selected or false.
In the PHP page.
if ($_post[' input's name value ']) {
Echo ' I was chosen ';
Here to write MySQL DELETE statement
}
It would be nice to have a while on the outside of this if statement.

$_post itself is an array.
Every tag is a single input, right? Each of the input has a name value,
LZ after the check click Submit (Submit), $_post[' This is the name value of input '] will be submitted to the PHP page.
If you select it, True is not selected or false.
In the PHP page.
if ($_post[' input's name value ']) {
Echo ' I was chosen ';
Here to write MySQL DELETE statement
}
It would be nice to have a while on the outside of this if statement.
Actually, I don't need a while circulating fluid.

Include (".. /conn/conn.php "); $array = Implode (", ", $_post[' flags ']); $query =" Delete from Tbl_user where ID in ($array) "; $sql = Mysql_q Uery ($query); if ($sql) {echo "";} Else{echo "";}

The text box is written like this:

When you POST the past, get it on the server: $id = $_post[' id ']; which column you check to get the value of which column.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.