Php mysql Data batch deletion implementation code

Source: Internet
Author: User

We generally obtain the data submitted by the form. If we use checkbox [] to perform this operation, we will look at the instance below.
-->

<Form id = "form1" name = "form1" method = "post" action = "">
1
<Input type = "checkbox" name = "checkbox []" id = "checkbox" value = "1"/>
2
<Input type = "checkbox" name = "checkbox []" id = "checkbox2" value = "2"/>
3
<Input type = "checkbox" name = "checkbox []" id = "checkbox3" value = "3"/>

<Input type = "submit" name = "button" id = "button" value = "submit"/>
</Form>


<?
If ($ _ post)
{
Print_r ($ _ post );
// The input is also saved as data,
/*
Array
(
[Checkbox] => array
(
[0] => 1
[1] => 2
[2] => 3
)
 
[Button] => submit
)
 
In this way, we only need
*/
$ Array = $ _ post ['checkbox'];
Print_r ($ array );
/*
The result is as follows:
 
Array
(
[0] => 1
[1] => 2
[2] => 3
)

In fact, 1, 2, and 3 are what we want. We can use SQL in to batch delete them.
*/
$ Ids = implode (',', $ array );
$ SQL = "delete from table name where id in ($ ids )";
Mysql tutorial _ query ($ SQL );
 
// Batch Delete the data.
// This site original reprint indicated source http://www.bKjia. c0m otherwise will be investigated!
}

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.