
Como eliminar registros de una tabla con php myadmin
Publicado por Adianec (6 intervenciones) el 23/05/2017 20:43:45
Hola necesito que por favor me ayuden, quiero hacer una tabla y que al darle clic en eliminar me elimine los registros en la base de datos.
Este es el codigo que tengo pero le doy clic en eliminar y no hace nada, y tampoco me da ningun error. Podrian ayudarme por favor.
Este es el codigo que tengo pero le doy clic en eliminar y no hace nada, y tampoco me da ningun error. Podrian ayudarme por favor.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include_once "../../includes/conexion2.php";
session_start();
/* PARTE 1: AL INICIO SE EXTRAEN TODAS LAS FILAS */
//Preparar la consulta para extraer todos los grupos
$consulta = "SELECT * FROM reportegrupos";
//Ejecutar la consulta
$resultado = mysql_query($consulta, $con) or die(mysql_error());
//Extraer todas la filas y almacenarlas en una tabla
$table = "<table border='2' cellpadding='1'>\n";
$table .= "<tr>
<th>Provincia</th>
<th>Municipio</th>
<th>Organismo</th>
<th>Id Cliente</th>
<th>Estado</th>
<th>Avería</th>
<th>Evento</th>
<th>Diagnostico</th>
<th>Potencia</th>
<th>Fecha Evento</th>
<th># Reporte</th>
<th></th></tr>\n";
while($fila = mysql_fetch_assoc($resultado)){
$table .= "<tr>
<td>".$fila["provincia"]."</td>
<td>".$fila["municipio"]."</td>
<td>".$fila["organismo"]."</td>
<td>".$fila["idCliente"]."</td>
<td>".$fila["estado"]."</td>
<td>".$fila["averia"]."</td>
<td>".$fila["evento"]."</td>
<td>".$fila["diagnostico"]."</td>
<td>".$fila["potencia"]."</td>
<td>".$fila["fechaEvento"]."</td>
<td>".$fila["numReporte"]."</td>
<td><form method='post' action=''> \n
<input type='hidden' name='ID' value='".$fila["idReporteGrupos"]."'>
<input type='submit' value='Eliminar'>
</form></td>
</tr>\n";
}
$table .= "</table>\n";
/* PARTE 2: SI SE ENVÍA EL FORMULARIO CAPTURAR LOS DATOS PARA ELIMINAR EL GRUPO */
if (isset($_POST["idReporteGrupos"]))
{
//Se almacena en una variable el id del registro a eliminar
$idReporteGrupos = $_POST["idReporteGrupos"];
//Preparar la consulta
$consulta = "DELETE FROM reportegrupos WHERE idReporteGrupos=$idReporteGrupos";
//Ejecutar la consulta
$resultado = mysql_query($consulta, $con) or die(mysql_error());
//redirigir nuevamente a la página para ver el resultado
header("location: Reportes/Reporte de eventos.php");
}
?>
Valora esta pregunta


0