0
需要刪除記錄,這裏是我的代碼:如何使用複選框在php中刪除記錄?
<input type="submit" name="delete" value="delete"/>
<?php
if(isset($_POST['delete']))
{
$cnt=array();
$cnt=count($_POST['chkbox']);
for($i=0;$i<$cnt;$i++)
{
$del_id=$_POST['chkbox'][$i];
$query="DELETE FROM menu_detail WHERE vt_id=".$del_id;
mysql_query($query);
}
}
?>
// I draw checkboxes using this where as I m fetching data from table...
<?php
$col = "row0"; $i = 0; $a=1;
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
if ($i == 0) { $col = "row0"; $i = 1; } else { $col = ""; $i = 0; }
?>
<tr class="<?php echo $col; ?>">
<td>
<input type="checkbox" name="chkbox" value="checkbox[<?php echo $row['vt_id']?>]" />
</td>
看圖像會給你一個想法,我是卡