Codice PHP:
//controllo se è stato inviato il modulo e se è stato selezionato almeno un checkbox
if(isset($_POST['submit']) && !empty($_POST['id_dati'])) {
$id = implode(', ', $_POST['id_dati']);
mysql_query("DELETE FROM MI_ingressi WHERE id IN($id)") or die(mysql_error());
printf ("Records eliminati: %d\n", mysql_affected_rows());
}
else { //altrimenti stampo il form
$query = mysql_query("SELECT * FROM MI_ingressi") or die(mysql_erro());
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
while($row = mysql_fetch_array($query)) {
echo "<input type=\"checkbox\" name=\"id_dati[]\" value=\"{$row['id']}\" />";
}
echo "<input type=\"submit\" name=\"submit\" value=\"Cancella\" /></form>";
}