PHP Bulk Operations Delete, support single Delete

Source: Internet
Author: User

PHP Execution Section:

1<?PHP2 include(' checkadmin.php ');3 Header(' content-type:text/html; Charset=utf-8 ');4 if($_post[' Btnsave ']){5     6     if(Empty($_post[' ID '])){7             Echo"<script>alert (' must select a product before it can be deleted! '); History.back ( -1);</script> ";8             Exit;9}Else{Ten         /*If you want to get all the values, use the following code*/ One          A         $id=implode(",",$_post[' ID ']); -         $str= "DELETE from ' product ' where ID in ($id)"; -         mysql_query($str); the         Echo"<script>alert (' Delete succeeded! '); window.location.href= ' product_list.php ';</script> "; -     } - } -?>

HTML Page section:

<form id= "Form2" name= "Form2" method= "post" action= "del_product.php" > <label> <input type= "checkb Ox "name=" id[] "value=" 1 "style=" background:none;  Border:none; "/> 1 </label> <label> <input type=" checkbox "Name=" id["" value= "2" Style= "Background:none;  Border:none; "/> 2 </label> <label> <input type=" checkbox "Name=" id["" value= "3" Style= "Background:none;  Border:none; "/> 3 </label> <label> <input type=" checkbox "Name=" id["" value= "4" Style= "Background:none;  Border:none; "/> 4 </label> <label> <input type=" checkbox "Name=" id["" value= "5" Style= "Background:none; Border:none; "/> 5 </label> <div style=" padding-left:20px; " > <input type= "button" value= "Select All" style= "Background:url (images/cheall.jpg) no-repeat; width:60px; height:23px; Border:none; "Onclick=" SelecTbox (' All ') "/> <input type=" button "value=" reverse select "style=" Background:url (images/cheall.jpg) no-repeat; width:60px; height:23px; Border:none, "onclick=" selectbox (' reverse ') "/> <input type=" Submit "Name=" Btnsave "style=" Background:url (imag es/cheall.jpg) No-repeat; width:60px; height:23px; Border:none; "value=" delete "/> </div></form>

JS Judgment section:

<script type= "Text/javascript" language= "JavaScript" >functionSelectbox (selecttype) {varCheckboxis = Document.getelementsbyname ("id[]"); if(SelectType = = "Reverse"){ for(vari=0; i<checkboxis.length; i++){ //alert (checkboxis[i].checked);checkboxis[i].checked =!checkboxis[i].checked; } } Else if(SelectType = = "All") { for(vari=0; i<checkboxis.length; i++){ //alert (checkboxis[i].checked);checkboxis[i].checked =true; } }}</script>

PHP Bulk Operations Delete, support single Delete

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.