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