这里有几件事:
您可以使用一个简单的选择器获得选中的复选框:
var inputs = $(':checkbox:checked');
在结果循环中生成复选框:
<?php
while($row = mysql_fetch_array($result)) :
?>
<tr>
<td><input type="checkbox" name="delete[]" value="<?= $row['User_Id']; ?>" /></td>
<td><?= $row['First_Name']; ?></td>
<td><?= $row['Last_Name']; ?></td>
<td><?= $row['Email_Address']; ?></td>
</tr>
<?php
endwhile;
此时您的删除处理程序是一个简单的WHERE..IN
查询:
// NOTE: Use an abstraction library to sanitize user-submitted data for the query
$filtered_delete_ids = implode(',', $_POST['delete']);
$query = "DELETE FROM `users` WHERE `User_Id` IN (".$filtered_delete_ids.")";