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> </th>
<th> </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> </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");
}
?>