欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php实现数据库批量删除的实例

程序员文章站 2022-03-25 16:35:38
...
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Title</title>
</head>
<body>
<? =  Mysqli("localhost","root","root","db_0808"(())?"":("链接错误" = "select * from student where is_delete='0'"?>
<form action="batch_delete.php" method="post">
<table border="1">
    <tr>
        <td>id</td>
        <td>名字</td>
        <td>性别</td>
        <td>班级</td>
        <td>生日</td>
        <td>操作</td>
        <td>选择</td>
    </tr>
    <?=->query( (=->
         ([2]==1[2]="男"  ([2]==0[2]="女"[2]="保密" ""?>
</table>

<form action="batch_delete.php" method="post">
<input type="submit" value="删除所选">
</form>
    <a href="add.php">新增用户</a>
</body>
</html>
<?php
/**
 * Created by fcc
 * User: Administrator
 * Date: 2017/10/17
 * Time: 15:16 
 */
 $ids=$_POST['ids'];
 $db=new Mysqli("localhost","root","root","db_0808");
 empty(mysqli_connect_error())?"":die("链接错误");
 //$sql="DELETE FROM student WHERE Sno='{$id}'";
 //彻底删除
 foreach ($ids as $i){$sql = "update student set is_delete = '1' where Sno= '{$i}'";
 //表面删除
 if ($db->query($sql)){    
 header("location:CURD.php");
};
};

以上就是php实现数据库批量删除的实例的详细内容,更多请关注其它相关文章!