Está basado en la función de eliminar registros de las librerías de PHP de Dreamweaver 8.
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST['id'])) && ($_POST['id'] != "")) {
$aLista = $_POST['id'];
$deleteSQL = sprintf("DELETE FROM mensajes WHERE id IN (".implode(',',$aLista).")",
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_conexionSQL, $conexionSQL);
$Result1 = mysql_query($deleteSQL, $conexionSQL) or die(mysql_error());
$deleteGoTo = "../../admin/mensajes/";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
// Aquí debe ir la consulta $row_registro que pongo de ejemplo en el formulario
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<?php if ($totalRows_registro > 0) { // Show if recordset not empty ?>
<form id="borraRegistro" name="borraRegistro" method="POST" action="index.php">
<input type="submit" value="Borrar registros marcados" />
<?php do { ?>
<input type="checkbox" name="id[]" value="<?php echo $row_registro['id'] ?>" title="Selecciona para luego Eliminar" />
<?php echo htmlentities($row_registro['titulo']); ?>
<?php } while ($row_bandeja_entrada = mysql_fetch_assoc($bandeja_entrada)); ?>
</form>
<?php } // Show if recordset not empty ?>
</body>
</html>