How to do batch deletion in PHP? _PHP Tutorial

WBOY
Release: 2016-07-13 10:27:13
Original
857 people have browsed it

How to do batch deletion in PHP? Please code

I am working on a project recently, but batch deletion has never been able to achieve the effect. I’ve posted the code below. Can you guys help me find out where the problem lies? Thank you very much!

//1. Batch deletion

 if($_POST["chk"]){

 $sid = implode(",", $_POST["chk"]);

$query = mysql_query("delete from news where news_id in (".$sid.")");

 if($query){

echo "";

 }

else {

echo "";

 }

 }

No matter how you delete it this way, it won’t work. Sometimes you can delete it by clicking Cancel. I don’t know why. Please ask an expert to answer it.

 ------Solution--------------------

Let’s echo the sql statement to see what is executed. If it doesn’t work, I’m thinking of other solutions

 ------Solution--------------------

This problem is easy to solve. Just print $_POST["chk"] and print the SQL statement and the problem will be solved

 ------Solution--------------------

It is recommended that you post your complete code

 ------Solution--------------------

echo "";

Your checkbox does not give a value.

 ------Solution--------------------

Click Cancel to delete because this sentence should be written like this:

There is also the del() function:

 if(num==0){

alert("Please select!");

return false;

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/820416.htmlTechArticleHow to do batch deletion in PHP? Please code. I am working on a project recently, but batch deletion has never been able to achieve the effect. . I posted the code below. Can you help me take a look? The problem lies in...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!