As far as I can tell, you are using the foreach loop correctly.
To be more pedantically correct:
if (isset($_POST['delete'], $_POST['id']) && is_array($_POST['id']))
{
foreach ($_POST['id'] as $id)
{
$id = (int)$id;
mysql_query("DELETE FROM backup WHERE ID=$id") or die(mysql_error());
}
}
else
{
echo "An error occurred during deletion process!<br />\n";
}
EDIT:
Of course, an even better way would be to execute just one SQL statement:
if (isset($_POST['delete'], $_POST['id']) && is_array($_POST['id']))
{
$ids = array();
foreach ($_POST['id'] as $id)
{
$ids[] = (int)$id;
}
if (count($ids) > 0)
{
$ids = implode(',', $ids);
mysql_query("DELETE FROM backup WHERE ID IN ($ids)")
or die(mysql_error()); // for debugging
}
}
else
{
echo "An error occurred during deletion process!<br />\n";
}