我有一个从数据库中获取数据的表,如下所示:(不是表单)
if (mysql_num_rows($result)) {
echo "<table id='logs' border='1' cellspacing='0' width='62%'>";
echo "<tr>";
echo "<th width='15%'>Time Registered</th>";
echo "<th width='15%'>Username</th>";
echo "<th width='15%'>Password</th>";
echo "<th width='15%'>IP Address</th>";
echo "<th width='2%'><a href=\"#\" onclick=\"checkAll(this);\">Mark</a></th>";
echo "<th width='2%'>Delete</th>";
echo "</tr>";
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
echo ("<p><td>$row[2]</td><td>$row[0]</td><td>$row[1]</td><td><i>$row[3]</i></td><td><center><input type=\"checkbox\" name=\"mark[]\"/></center></td><td><a href=\"delete.php?time=$row[2]&user=$row[0]&pass=$row[1]&ip=$row[3]\"><center>[x]</center></a></td></p>");
echo "</tr>";
}
echo "</table>";
}
那个部分<input type=\"checkbox\" name=\"mark[]\"/>
是复选框。如何找到并处理选中的复选框?
if(mark[$checked]) {
//delete data from database if row checked
}
foreach($_REQUEST['mark'] as $value){
echo "$value was selected\n <br />";
}
如果你想知道哪个没有被选择,那么将所有可能的选择存储到一个数组中,然后遍历该数组并执行类似的操作
foreach($poss_select as $key=>$val){
if(!in_array($val,$_REQUEST['mark']){
$not_selected[$key] = $value;
}else{
deleteRow($value);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)