checkbox删除多项
<无详细内容>
<form action="delete.php" method="post"> <thead> <tr> <th><input class="check-all" type="checkbox" /></th> <th>ID</th> <th>Name</th> </tr> </thead> <tbody> <?php foreach($adminlist as $arritem) { ?> <tr> <td> <input name='select[]' value="<?php echo $arritem['id'];?>" type="checkbox" /> //这里的name很重要,到delete.php中会调用 </td> <td><?php echo $arritem['id'];?></td> <td><?php echo $arritem['name'];?></td> </tr> <?php } ?> </tbody> <input type="submit" value="Delete all selected" onclick="javascript:return confirm("Are you sure?")"/> </form> delete.php <?php $link=mysql_connect("localhost","root",""); mysql_select_db("dbname"); $id=$_POST['select']; //调用input的name foreach($id as $ide){ $exec="delete from tablename where sID=$ide"; $result=mysql_query($exec); if((mysql_affected_rows()==0) or (mysql_affected_rows==-1)) { echo "没有找到记录,或者删除时出错"; exit; } else{ echo "学生信息已经删除"; } } mysql_close(); ?>
精彩图集
精彩文章