Pongo todo completo para que lo analicen!
Código PHP:
<?php require_once('Connections/conexion.php'); ?>
<?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["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tabla (id, nombre, telefono) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['telefono'], "int"));
mysql_select_db($database_conexion, $conexion);
$Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
$insertGoTo = "/cel.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conexion, $conexion);
$query_cels = "SELECT * FROM tabla ORDER BY id ASC";
$cels = mysql_query($query_cels, $conexion) or die(mysql_error());
$row_cels = mysql_fetch_assoc($cels);
$totalRows_cels = mysql_num_rows($cels);
?>
<?php
$link = mysql_connect("localhost", "elcapito_daecorp", "seifer");
mysql_select_db("elcapito_celulares", $link);
if (isset($_POST['eliminar_seleccion']))
if (count($_POST['seleccion']))
foreach($_POST['seleccion'] as $id => $valor)
mysql_query("DELETE FROM tabla WHERE id = ".$id." LIMIT 1", $link);
?>
<!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>
<style type="text/css">
<!--
body,td,th {
font-family: Segoe UI, Arial;
font-size: 12px;
}
-->
</style></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="95%" border="0" cellpadding="5">
<tr bgcolor="#CCCCCC">
<td width="3%">ID</td>
<td width="45%">Nombre</td>
<td width="49%">Telefono</td>
<td width="3%"> </td>
</tr>
<?php
$result = mysql_query("SELECT * FROM tabla", $link);
while ($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['nombre']; ?></td>
<td><?php echo $row['telefono']; ?></td>
<td><input type="checkbox" name="seleccion[<?php echo $row['id']; ?>]" /></td>
</tr>
<?php
}
?>
</table>
<input name="eliminar_seleccion" type="submit" value="Eliminar Seleccion" />
</form>
<p> </p>
<p> </p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="nombre" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Telefono:</td>
<td><input type="text" name="telefono" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($cels);
?>