Como puedo editar un combobox con datos ya guardados anteriormente en php y mysql?
Publicado por Dago (12 intervenciones) el 03/03/2019 01:22:32
Tengo un formulario con el que guardo datos del nombre del usuario y su signo zodiacal pero quisiera que al editar los datos me envie al formulario editar y jale los datos que guarde e igual en el cmbobox que tome el dato que guarde pero no se como hacerlo y ya he buscado y no he encontrado este es el código de la tabla donde muestra mis datos guardados al darle editar mandar al form donde editara (Puedo mandar los datos a editar sin problema al form editar solo me haria falta tomar el dato ya guardado en el combobox) Si en el registro 1 guarde "Tauro" cuando de editar esten los datos y en el cmbobox aparezca "Tauro" espero me puedan ayudar
y este es mi form de editar
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
<?php
include "conexion.php";
$sql="SELECT * FROM simbolos";
$resul = $cone->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<center>
<h2>Datos</h2>
<table border="1">
<thead>
<tr>
<th>Codigo</th>
<th>Nombre</th>
<th>Signo</th>
<th>Comando</th>
</tr>
</thead>
<tbody>
<?php while ($row = $resul->fetch_assoc())
{?>
<tr>
<td><?php echo $row['Id_pro'];?></td>
<td><?php echo $row['Signo'];?></td>
<td><?php echo $row['Producto'];?></td>
<td><a href="editpro.php?Id_pro=<?php echo $row['Id_pro']; ?>"><span class="glyphicon glyphicon-pencil">Posponer</span></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</center>
</body>
</html>
y este es mi form de editar
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
<?php
include "conexion.php";
$id = $_GET['Id_pro'];
$sql = "SELECT Id_pro, Signo, Nombre FROM simbolos
where Id_pro = '$id'";
$rec = $cone->query($sql);
$row = $rec->fetch_assoc();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<center>
<h1>Editar Combobox</h1>
<form action="editpro.php" method="POST">
<label>Codigo</label>
<input type="text" name="cod" value="<?php echo $row['Id_pro'];?>"><br><br>
<label>Nombre</label>
<input type="text" name="nom" value="<?php echo $row['Nombre'];?>"><br><br>
<label>Signo Zodiacal</label>
<select name="signo">
<option value="Aries">Aries</option>
<option value="Tauro">Tauro </option>
<option value="Geminis">Geminis </option>
<option value="Cancer">Cancer</option>
<option value="Leo ">Leo </option>
<option value="Virgo">Virgo</option>
<option value="Libra">Libra</option>
<option value="Escorpio">Escorpio</option>
<option value="Sagitario">Sagitario</option>
<option value="Capricornio">Capricornio</option>
<option value="Acuario">Acuario</option>
<option value="Piscis">Piscis</option>
</select><br><br>
<input type="submit" name="editar" value="Editar">
</form>
</center>
</body>
</html>
Valora esta pregunta


0