触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > PHP checkbox批量提交方法

PHP checkbox批量提交方法
例一:
<input type="checkbox" name="pp[]" id="pp" value="<?php echo $rspp->Fields(XNAME);?>" />

<?
......
$str_pp = "";
$pp = $_POST['pp'];
for($i=0;$i<count($pp);$i++)
   {
    if($i==0){
     $str_pp = $pp[$i];
    }else{
     $str_pp = $str_pp.",".$pp[$i];
    }
   }
......
$conn->execute("INSERT INTO [Products] (Title,Content,pp,gg,jj) VALUES ('$Title','$Content','$str_pp','$str_gg','$str_jj')");
echo "<script>alert('添加成功!');location='ADDProducts.php';</script>";
}
?>

例二:
<input name="del_id[]" type="checkbox" id="del_id[]" value="<?php echo $rs->Fields(id);?>" />

<?
$action=$_POST['action'];
$array = $_POST[del_id]; //将所选的值组成的数组放入$array数组
$delid    = implode(",",$array);
if($action=='del'){
$conn->execute ("delete from [News] where id in (".$delid.")");
echo "<script type='text/javascript'>alert('删除成功!');window.location.href='News_Manage.php';</script>";
}    
?>

例三:批量修改
<input name="del_id[]" type="checkbox" id="del_id[]" value="<?php echo $rs->Fields(id);?>" />

<?
$action=$_POST['action'];
$array = $_POST[del_id]; //将所选的值组成的数组放入$array数组
$delid    = implode(",",$array);
if($action=='del'){
$rs=new COM("adodb.recordset");
$rs->open("UPDATE [Products] SET state = 3 where id in (".$delid.")",$conn,1,1);
echo "<script type='text/javascript'>alert('处理成功!');window.location.href='Productstj_Manage.php';</script>";
}    
?>


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com