2017.5.4

批量删除

<h1>民族信息</h1>
<form action="shanchu.php" method="post">
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td><input type="checkbox" name="qx" οnclick="quanxuan(this)" />代号</td>
<td>名称</td>
</tr>

<?php
require "./DBDA.class.php";
$db = new DBDA();

$sql = "select * from nation";
$arr = $db->query($sql);

foreach($arr as $v)
{
echo "<tr>
<td><input type='checkbox' name='ck[]' class='ck' value='{$v[0]}' />{$v[0]}</td>
<td>{$v[1]}</td>
</tr>";
}
?>

</table>

<input type="submit" value="批量删除" />

</form>
</body>
<script type="text/javascript">
function quanxuan(qx)
{
var ck = document.getElementsByClassName("ck");
if(qx.checked)
{
for(var i=0;i<ck.length;i++)
{
ck[i].setAttribute("checked","checked");
}
}
else
{
for(var i=0;i<ck.length;i++)
{
ck[i].removeAttribute("checked");
}
}
}
</script>

 

 

操作界面代码

<?php
$arr = $_POST["ck"];

require "./DBDA.class.php";
$db = new DBDA();

// delete from nation where code in('n001','n002','n003')

$str = implode("','",$arr);

$sql = "delete from nation where code in('{$str}')";
echo $sql;
if($db->query($sql,0))
{
header("location:piliangshanchu.php");
}

转载于:https://www.cnblogs.com/nzhcww/p/6807035.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值