Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/02/2016, 13:00
sentoki79
 
Fecha de Ingreso: octubre-2013
Mensajes: 79
Antigüedad: 10 años, 6 meses
Puntos: 1
Respuesta: Problemas codigo al hacer un delete

Gracias por tratar de echarme una mano compañero, incluyo el codigo:


<html>

<head>
<title>Usuarios</title>
<META name='robot' content='noindex, nofollow'>
</head>

<?php




$conexion=mysqli_connect("localhost","root","","us uarios")or die("Problemas con la conexión");
$registros=mysqli_query($conexion,"select * from usuarios")or
die("Problemas en el SELECT:".mysqli_error($conexion));
while($reg=mysqli_fetch_array($registros))
{
$Id=$reg['Id'];

echo "
<body>

<div align='center'>
<table border='0' width='600' style='font-family: Verdana; font-size: 8pt' id='table1'>

<form method='POST' action='form2.php'>
<tr>
<td colspan='1'><p align='center'><b>Id: </b></td>
<td width='50%'><p align='center'><b>nombre usuario:</b></td>
<td width='50%'><p align='center'><b>contrasenya:</b></td>
<td width='50%'><p align='center'><b>nombre :</b></td>
<td width='50%'><p align='center'><b>primer apellido:</b></td>
<td width='50%'><p align='center'><b>segundo apellido:</b></td>
<td width='50%'><p align='center'><b>DNI:</b></td>
<td width='50%'><p align='center'><b>Email:</b></td>
<td width='50%'><p align='center'><b>Telefono:</b></td>
<td width='50%'><p align='center'><b>Privilegios:</b></td>
</tr>
<tr>

<td colspan='1'> <input type='checkbox' name='Id[]' value=".$Id."><span name='id'>".$reg['Id']."</span></td>

<td width='50%'><p align='center'><input type='text' name='user' size='10' value='".$reg['NombreUsuario']."'></td>

<td width='50%'><p align='center'><input type='text' name='password' size='10' value='".$reg['Password']."'>

<td width='50%'><p align='center'><input type='text' name='nombre' size='10' value='".$reg['Nombre']."'></td>

<td width='50%'><p align='center'><input type='text' name='apellido1' size='10' value='".$reg['Apellido1']."'>

<td width='50%'><p align='center'><input type='text' name='apellido2' size='10' value='".$reg['Apellido2']."'>

<td width='50%'><p align='center'><input type='text' name='DNI' size='10' value='".$reg['DNI']."'>

<td width='50%'><p align='center'><input type='text' name='email' size='10' value='".$reg['Email']."'>

<td width='50%'><p align='center'><input type='text' name='telefono' size='10' value='".$reg['Telefono']."'>

<td width='50%'><p align='center'><input type='text' name='privilegio' size='10' value='".$reg['Privilegio']."'>

<tr>
<td width='50%'>&nbsp;</td>
<td width='50%'>&nbsp;</td>
</tr>
<input type='hidden' name='id' value='".$reg['Id']."'>
<tr>
<td width='100%' colspan='2'>
<p align='center'>
<input type='submit' value='Actualizar datos' name='B1'></td>
</tr>
</form>
</table>
<tr/>
</div>

";
}
if(isset($_POST["Id"])) {
$delete = $_POST["Id"];
$cantidad = count($delete);
for ($i=0; $i<$cantidad; $i++) {
$del_id = $delete[$i];
mysqli_query($conexion,"DELETE FROM usuarios WHERE Id='".$del_id."'")or
die("Problemas en el DELETE:".mysqli_error($conexion));
}

echo "<script>alert('Elementos eliminado');</script>";

echo "<script language='JavaScript'>window.self.location='BBDD_u suarios.php';</script> ";
}


echo"
<form method='post' action='form2.php'>
<input type='submit' name='borrar' value='Borrar fila'>
</form>

<form method='post' action='Nuevo_Usuario.php'>
<input type='submit' name='nuevo' value='Introducir nuevo'>
</form>
";
mysqli_close($conexion);
?>

</body>

</html>