Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/07/2012, 08:50
Chelo1982
 
Fecha de Ingreso: agosto-2008
Mensajes: 97
Antigüedad: 15 años, 8 meses
Puntos: 1
Borrar dato del sql con php

Hola estoy tratando de borrar unos datos de la base de datos y tengo los siguientes archivos. El tema que me trae todo los datos pero al darle click en eliminar no hace nada. Les dejo el codigo mil gracias!!!


Código PHP:
<?php
require("conexion.php");
require(
"funciones.php");

$query "SELECT * FROM usuarios ORDER BY NOMBRE_USUARIO ASC";
$queEmp mysql_query($query$conexion);
?>
<!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=UTF-8" />
<title>Listado de Empresas</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Listado de  Empresas</h3>
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th>Nombre</th>
    <th>Dirección</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
  <?php while ($rsEmp mysql_fetch_assoc($queEmp)) { ?>
  <tr>
    <td><?php echo $rsEmp['NOMBRE_USUARIO']; ?></td>
    
    
    <td><a href="#" onclick="delEmpresa(<?php echo $rsEmp['ID_USUARIO']; ?>);">Eliminar</a></td>
  </tr>
  <?php ?>
</table>
<script type="text/javascript">
function delEmpresa(ID_USUARIO) {
    if (window.confirm("Aviso:\nDesea eliminar el registro seleccionado?"))    {
        window.location = "delete.php?action=del&id="+ID_USUARIO;    
    }
}
</script>
<p>&nbsp;</p>
</body>
</html>
Código PHP:
<?php
require("conexion.php");
require(
"funciones.php");

$idempresa getParam($_GET["ID_USUARIO"], "-1");
$action getParam($_GET["action"], "");

if (
$action == 'del') {
    
$sql "DELETE FROM usuarios WHERE ID_USUARIO = ".sqlValue($idempresa"int");
    
mysql_query($sql$conexion);
    
header("location: listado.php");
}
?>