我试图用检查箱删除多个记录。 我把每个检查箱装上记录索引:
<?php $row_count = 1; do { ?>
<tr <?php if ($row_count%2) { ?>bgcolor="#F4F4F4"<?php } ?>>
<td align="center" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_contactlist[ contact_id ]; ?>"></td>
<td align="center" ><p><?php echo $row_contactlist[ contact_id ];?></p></td>
</tr>
<?php $row_count++; } while ($row_contactlist = mysql_fetch_assoc($contactlist)); ?>
使用以下链条删除:
<a class="addcontact" href="delete.php?mContact=<?php for($i=0;$i<=$row_count;$i++) { $del_id = $checkbox[$i]; } echo $del_id ?>" style="border-bottom:0px" >Delete Contact(s)</a>
删除。 php
if (isset($_GET[ mContact ])) {
mysql_query("DELETE FROM contacts WHERE contact_id = ".$_GET[ mContact ]."");
mysql_query("DELETE FROM history WHERE history_contact = ".$_GET[ mContact ]."");
mysql_query("DELETE FROM notes WHERE note_contact = ".$_GET[ mContact ]."");
redirect( You have deleted some contacts ,"contacts.php");
}
间接工程,即与你接触的网页重载,已经删除了某些接触,它像我一样没有错误,但没有任何接触被删除。
UPDATE: Thanks guys very speedy response. Total newb to PHP so everything is massively appreciated.
因此,我用的是一笔总账,而不是一个超级链接:
<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>