Home  >  Article  >  Backend Development  >  PHP mysql data batch deletion code_PHP tutorial

PHP mysql data batch deletion code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:05:381007browse

We usually obtain the data submitted by the form. If we use checkbox[] to operate below, see an example below.
-->


1

2

3




if( $_post )
{
print_r( $_post );
//Input is also saved in the form of data,
/*
array
(
[checkbox] => array
(
[0] => 1
[1] => 2
[2] => 3
)

[button] => Submit
)

This is easy to operate, we only need to do the following
*/
$array = $_post['checkbox'];
print_r( $array );
/*
The content obtained is as follows

array
(
[0] => 1
[1] => 2
[2] => 3
)

In fact, 1, 2, and 3 are what we want, and we can use sql's in to delete them in batches.
*/
$ids = implode(',',$array );
$sql ="delete from table name where id in($ids ) ";
mysql tutorial_query($sql);

//This will achieve batch deletion of data.
// Please indicate the source of original reprints on this site: http://www.bKjia.c0m Otherwise, we will investigate!
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630761.htmlTechArticleWe usually get the data submitted by the form. If we use checkbox[] to operate below, see the example below. -- form id=form1 name=form1 method=post action= 1 input type=checkbox...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn