日期:2014-05-17 浏览次数:20518 次
<SCRIPT language=javascript>
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
</SCRIPT>
<body>
<form name=myform method='post' action='' onsubmit='return checkdata();'>
<table width="502" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td colspan="5" align="center" valign="middle" bgcolor="#666666"><span class="STYLE2">用户管理</span></td>
</tr>
<tr>
<td width="37" align="center" bgcolor="#FFFFFF"><input type="checkbox" name="chkall" onClick="javascript:CheckAll(this.form)"></td>
<td width="145" align="center" bgcolor="#FFFFFF"><strong>用户名</strong></td>
<td width="94" align="center" bgcolor="#FFFFFF"><strong>状态</strong></td>
<td width="95" align="center" bgcolor="#FFFFFF"><strong>编辑</strong></td>
<td width="95" align="center" bgcolor="#FFFFFF"><strong>删除</strong></td>
</tr>
<?php
while($Row=mysql_fetch_array($result))
{
$wyx_id=$Row["wyx_id"];
$wyx_name=$Row["wyx_name"];
$wyx_pass=$Row["wyx_pass"];
?>
<tr>
<td width="37" align="center" bgcolor="#FFFFFF"><input type="checkbox" value=""></td>
<td width="145" align="center" bgcolor="#FFFFFF"><?php echo $wyx_name ?></td>
<td width="94" align="center" bgcolor="#FFFFFF"></td>
<td width="95" align="center" bgcolor="#FFFFFF"><a href="admin_useredit.php?id=<?php echo $wyx_id ?>">编辑</a></td>
<td width="95" align="center" bgcolor="#FFFFFF"><a href="admin_userdel.php?id=<?php echo $wyx_id ?>">删除</a></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<input type=submit name=submit value=删除>
</td>
</tr>
</table>
</form>
</body>
$wyx_id=$_POST['wyx_id'];
foreach($wyx_id as $value)
{
$sql="delete from table where id=$value";
}
这样就OK了
------解决方案--------------------
<input type="checkbox" name="ids[]" value="这里要输入id">
post 过去就是
$ids[0]=id1;
$ids[1]=id2; 这个形式,楼上的已经说的很明白了.
------解决方案--------------------
多条主要用条件语句来控制。
比如说id in ...,或者id > ... 又或者 id not in ...
等等。
------解决方案--------------------