HPH-——>mysql 大量刪除

來源:互聯網
上載者:User

標籤:設定   刪除   asc   div   action   classname   meta   xhtml 1.0   提交   

大量刪除

 

va<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title></head><body><br /><form action="main.php" method="post"><div>姓名:<input type="text" name="xm" /> <input type="submit" value="查詢" /></div></form><br /><form action="piliangshanchu.php" method="post"><table width="100%" border="1" cellpadding="0" cellspacing="0">    <tr>        <td><input type="checkbox" onclick="quanxuan(this)" />代號</td>        <td>姓名</td>        <td>性別</td>        <td>民族</td>        <td>生日</td>        <td>操作</td>    </tr>        <?php        //先判斷有沒有提交值    $xxm = "";    $tj = " 1=1 ";    if(!empty($_POST["xm"]) && $_POST["xm"]!="")    {        $xxm = $_POST["xm"];        $tj = " name like ‘%{$xxm}%‘ ";    }        //造連線物件    $db = new  MySQLi("localhost","root","123","mydb");    //寫SQL語句    $sql = "select * from info where ".$tj;    echo $sql;    //執行SQL語句    $result = $db->query($sql);    //讀資料    $attr = $result->fetch_all();        foreach($attr as $v)    {        echo "<tr>";                $sex = $v[2]?"男":"女";                //根據名族代號查詢名族名稱        $name = NationName($v[3]);                //替換關鍵字        $newname = str_replace($xxm,"<mark>{$xxm}</mark>",$v[1]);                echo "<td><input type=‘checkbox‘ value=‘{$v[0]}‘ name=‘sc[]‘ class=‘qx‘ />{$v[0]}</td><td>{$newname}</td><td>{$sex}</td><td>{$name}</td><td>{$v[4]}</td><td><a href=‘shanchu.php?c={$v[0]}‘ onclick=\"return confirm(‘確定刪除嗎?‘)\">刪除</a><a href=‘xiugai.php?c={$v[0]}‘>修改</a></td>";                /*foreach($v as $v1)        {            echo "<td>{$v1}</td>";        }*/                echo "</tr>";    }        //給一個民族代號,返回民族名稱    function NationName($code)    {        //造連線物件        $db = new  MySQLi("localhost","root","123","mydb");        //寫SQL語句        $sql = "select name from nation where code=‘{$code}‘";        //執行SQL語句        $result = $db->query($sql);                $attr = $result->fetch_row();                return $attr[0];    }        ?>        </table><a href="add.php"><input type="button" value="添加資料" /></a><input type="submit" value="大量刪除" onclick="return confirm(‘確定刪除麼‘)" /></form><script type="text/javascript">function quanxuan(a){    //找到下面所有的複選框    var ck =document.getElementsByClassName("qx");        //遍曆所有複選框,設定選中狀態    for(var i=0;i<ck.length;i++)    {        if(a.checked)        {            ck[i].setAttribute("checked","checked");        }        else        {            ck[i].removeAttribute("checked");        }    }    }</script></body></html>大量刪除處理<?php$attr = array();if(!empty($_POST["sc"])){    $attr = $_POST["sc"];}$db = new  MySQLi("localhost","root","123","mydb");/*foreach($attr as $v){    $sql = "delete from info where code=‘{$v}‘";        $db->query($sql);}*/$str = implode("‘,‘",$attr);//echo $str;$sql = "delete from info where code in(‘{$str}‘)";$db->query($sql);//delete from info where code in(‘p001‘,‘p002‘,‘p003‘)

 

HPH-——>mysql 大量刪除

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.