boton eliminar de tabla mysql
Publicado por Yuki (1 intervención) el 21/02/2018 16:45:38
Hola a todos, tengo un problema con mi código ,tengo una consulta que me arroja los registros existentes de una tabla, le agregue un botón de eliminar, pero no se que es lo que tengo mal, no me elimina nada, por favor si alguien me puede ayudar?Gracias.
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
$conexion = mysqli_connect("host",
"user","pass");
mysqli_select_db($conexion,"db3987528_moodle");
$tildes=$conexion->query("set name 'utf8'");
$sql = "select * from mdl_groups ORDER BY id desc";
$result=mysqli_query($conexion,$sql);
echo "<table>";
echo "<tr>";
echo "<th>Id</th>";
echo "<th>Denominacion</th>";
echo "<th>Asistentes</th>";
echo "<th>Inicio</th>";
echo "<th>Fin</th>";
echo "<th width=\"10%\">Sesiones</th>";
echo "<th>Empresas</th>";
echo "<th>Profesores</th>";
echo "</tr>";
while($reg =mysqli_fetch_row($result))
{
echo"<tr>";
echo"<td>".$reg[2]."</td>";
echo"<td>".$reg[3]."</td>";
echo"<td>".$reg[7]."</td>";
echo"<td>".$reg[8]."</td>";
echo"<td>".$reg[9]."</td>";
echo"<td>".$reg[10]."</td>";
echo"<td>".$reg[11]."</td>";
//boton eliminar
echo"<td><form method=post action=grupos.php>";
echo"<input type='hidden' name='id' value='".$fila['id']."'>";
echo"<input type=submit value=Eliminar name=Eliminar>";
echo"</form></td>";
echo"</tr>";
}
echo"</table>";
if (isset($_POST["Eliminar"]))
{
$id=$_POST["id"];
$sql="DELETE * FROM db3987528__groups where mdl_groups.id=$id";
$result=mysqli_query($sql,$conexion)or die (mysql_error());
header("location:grupos.php");
}
?>
<?php
mysqli_close($conexion);
Valora esta pregunta


0