Home>Article>Backend Development> 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!