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");
    }

  • 相关阅读:
    Uva 10935 Throwing cards away I
    Uva 3226 Symmetry
    eclipse @ 注释为何一写就报错
    2015省赛小感想
    Zoj 3842 Beauty of Array
    fedora 设置命令别名
    Uva220 Othello
    工作小技巧积累
    SSL介绍与Java实例
    一个完整的SSL连接建立过程
  • 原文地址:https://www.cnblogs.com/nzhcww/p/6807035.html
Copyright © 2011-2022 走看看