zoukankan      html  css  js  c++  java
  • 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" onclick="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");
    }

  • 相关阅读:
    如何设置IIS实现无扩展名重写
    正则表达式基础知识
    Literal控件用法
    ajaxPro.dll基础教程
    PetShop的系统架构设计
    SQL点滴29—错误无处不在
    javascript中的正则表达式
    为什么开发环境如此之乱
    SQL点滴文章总结
    javascript读写cookie
  • 原文地址:https://www.cnblogs.com/nzhcww/p/6807035.html
Copyright © 2011-2022 走看看