Rumah > Artikel > pembangunan bahagian belakang > 新手求指教!jQuery实现全选与批量删除?该如何解决
新手求指教!jQuery实现全选与批量删除??
这是数据库循环取出来的ID
<?php if($_SERVER['REQUEST_METHOD'] === "POST"){ foreach($_POST as $chk => $post){ $pos = strpos($chk,"check"); if(!$pos === false) $ids[] = $post; } if(count($ids) > 1) $id = implode(",",$ids); else $id = implode($ids); $sql = "DELETE FROM [table] WHERE id IN (".$id.")"; $result = mysql_query($sql,$conn); if(!$result) die("SQL: {$sql} <br>Error: " . mysql_error() ); if(mysql_affected_rows() > 0) echo "<script>alert('已批量删除');</script>"; else echo "<script>alert('批量删除失败\nError:".mysql_error()."');</script>"; } ?> <?php foreach($rows as $row){ ?> <td><input type="checkbox" name="check[]" value="<?php echo $row['adm_id'] ?>"></td> <?php } ?> <div class="clear"> </div>