Home  >  Article  >  Backend Development  >  PHP batch deletion of data_PHP tutorial

PHP batch deletion of data_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:15852browse

php tutorial batch delete data
Data are separated by commas.
Form:








Well $ID_Dele=$_POST['ID_Dele'] will be an array. Although PHP is weakly typed, it is not as weak as ASP.
ASP can directly:
SQL="delete from [doing] where id in ('"&ID_Dele&"')" to delete. But PHP cannot put $ID_Dele directly into it. Because $ID_Dele is not '1,2,3,4', because $ID_Dele is an array with keys and values.
Well, it’s not difficult in PHP. There happens to be a function: implode(), that’s right. A function that has exactly the opposite function to split()explode(). The latter two are separated by a certain character (such as a comma), while the former can be spliced ​​into a string.
Therefore:
$ID_Dele= implode(",",$_POST['ID_Dele']);
$SQL="delete from `doing` where id in ($ID_Dele)";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630880.htmlTechArticlephp tutorial batch deletion of data Data is separated by commas. Form: form action= method=post input name=ID_Dele[] type=checkbox id=ID_Dele[] value=1/ input name=ID_Dele[] 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