<?php教程 session_start();?>
<!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>
<?php include 'conf/conn.php';?>
<div id="wrapper">
<div id="header"><h1>留言管理 </h1></div><h2>
<?php echo "你好!管理員:".@$_SESSION['name']." <a href='login.php'>退出</a>";?></h2>
<div id="listDiv">
<form method="POST" action="" name="listForm">
<table>
<tr>
<td><input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox"> ID號</td><td>用戶名</td><td>標題</td><td>內容</td>
</tr>
<?php //數據庫教程查找返回數組
$result_gl = mysql教程_query("SELECT * FROM message");
while($row = mysql_fetch_array($result_gl)){
?>
<tr>
<td><input type="checkbox" name="checkboxes[]" /></td>
<td> <?php echo $row['id']?></td>
<td ><?php echo $row['user'];?></td>
<td><?php echo $row['title']?></td>
<td><?php echo $row['content']?></td>
</tr>
<?php
}
?>
<tr>
<td><input type="submit" name="delet" value="刪除留言" /></td>
</tr>
</table>
</div>
</form>
<?php
include 'END.php';
?>
</div>
</body>
</html>
實例方法
$ids=$_POST['ids'];
$where="";
foreach($ids as $key => $val) {
if(!empty($where)){
$where.=", '".$val."'";
}else{
$where.="'".$val."'";
}
}
mysql_query("DELETE FROM message where id in ($where)");