php一次性删除前台checkbox多选内容的方法_php实例
May 17, 2016 am 08:55 AM
php
复制代码 代码如下:
SQL:$SQL="delete from `doing` where id in ('1,2,3,4')";
数据用逗号隔开。
表单:
复制代码 代码如下:
好$ID_Dele=$_POST['ID_Dele']将会是一个数组,虽然说PHP是弱类型的,但这里可没ASP弱。
ASP可以直接:
SQL="delete from [doing] where id in ('"&ID_Dele&"')"进行删除。但PHP不能把$ID_Dele直接放进去。因为$ID_Dele可不是'1,2,3,4'哦,因为$ID_Dele是一个数组,具有键和值。
好,PHP中也不难,刚好有个函数:implode(),对了。同split()\explode()功能刚好相反的一个函数,后两者是用某字符(比如逗号)分割的,而前者则可以拼接为字符串。
因此:
复制代码 代码如下:
$ID_Dele= implode(",",$_POST['ID_Dele']);
$SQL="delete from `doing` where id in ($ID_Dele)";
Statement of this Website
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
