Home>Article>Backend Development> How to delete data in batches in php

How to delete data in batches in php

Guanhui
Guanhui Original
2020-05-11 15:08:35 2830browse

How to delete data in batches in php

How to implement batch deletion of data in php

First, submit the ID of the data to be deleted on the front end to the backend php in the form of an array; Then use "$_GET" in php to get the data ID to be deleted, and finally connect to the MySQL database to delete the data one by one or use "IN" to delete it all at once.

Sample code

HTML:

PHP:

if($_POST['btnSave']){ if(empty($_POST['id'])){ echo""; exit; } else { /*如果要获取全部数值则使用下面代码*/ $id= implode(",",$_POST['id']); $str="DELETE FROM `product` where id in ($id)"; mysql_query($str); echo ""; } }

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to delete data in batches in php. For more information, please follow other related articles on the PHP Chinese website!

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