PHP - Problemas con combobox en PHP y mysql

 
Vista:

Problemas con combobox en PHP y mysql

Publicado por Cristina (1 intervención) el 04/08/2015 00:44:08
Buenas tardes:

Le escribo para solicitarles su ayuda, estoy trabajando en un inventario, donde no había tenido problemas hasta ahora que estoy en la parte de Actualizar algún registro... El problema radica en que, aunque carga los datos en los combobox, al momento de guardar, lo hace, pero con todos en blanco... Ya me canse de investigar, he hecho todo lo que se dice, pero no he tenido éxito. De antemano, les agradezco su apoyo.

Les comparto el código de la primer página. [b] Tel_Modificar_Id.php

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php require_once('Connections/final.php');
mysql_query("SET NAMES 'utf8'");
?>
<?php
?>
<?php
//error_reporting(E_ALL ^ E_NOTICE);  
	   	$query="select * from sede";
		$res=mysql_query($query);
 
 
	   	$query1="select * from departamento";
		$res1=mysql_query($query1);
 
		$query2="select * from resguardante";
		$res2=mysql_query($query2);
 
//consulta para mostrar los datos.
 
$consulta=mysql_query("SELECT * FROM tel_ip WHERE Id=". $_REQUEST["cod"]);
$res_consulta=mysql_fetch_array($consulta);
 ?>
<!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>Documento sin título</title>
</head>
<body>
<p> Teléfonos IP</p>
<form id="form1" name="form1" method="POST" action="Tel_Modificar_Id_Guardar.php?cod=<?php echo $_REQUEST["cod"]; ?>">
  <table width="495" border="1">
    <tr>
      <td width="142">Id</td>
      <td width="337"><input name="Id" type="text" id="Id" value="<?php echo $res_consulta["Id"]?>" size="20" /></td>
    </tr>
    <tr>
      <td>Marca</td>
      <td><label for="marca"></label>
        <label for="marca2"></label>
        <select name="marca" id="marca2">
       <option selected="" value="" ><?php echo $res_consulta["Marca"]?></option>
          <option>Polycom</option>
          <option>Digium</option>
      </select></td>
    </tr>
    <tr>
      <td>Modelo</td>
      <td><input name="modelo" type="text" id="modelo" value="<?php echo $res_consulta["Modelo"]?>" size="50" /></td>
    </tr>
    <tr>
      <td>Estado</td>
      <td><label for="estado"></label>
        <select name="estado" id="estado">
          <option selected="" value="" ><?php echo $res_consulta["Estado"]?></option>
          <option>Bueno</option>
          <option>Regular</option>
          <option>Malo</option>
        </select></td>
    </tr>
    <tr>
      <td>En uso</td>
      <td><select name="uso" id="uso">
      <option selected="" value="" ><?php echo $res_consulta["En_uso"]?></option>
        <option>Si</option>
        <option>No</option>
      </select></td>
    </tr>
    <tr>
      <td>Número de Serie y/o Observaciones</td>
      <td><p>
        <textarea name="obser" cols="50" id="modelo2"><?php echo $res_consulta["Observaciones"]?></textarea>
      </p></td>
    </tr>
    <tr>
      <td>Sede</td>
      <td><label for="sede"></label>
      </select>
      <select name="sede" >
      <option selected="" value="" ><?php echo $res_consulta["Sede"]?></option>
      <?php    while($row=mysql_fetch_array($res))
	  		{
		?>
      <option value="<?php echo $row['sede']?>"> <?php echo utf8_encode($row['sede']);?></option>
      <?php } ?>
      </select>
      </td>
    </tr>
    <tr>
      <td>Departamento</td>
      <td><label for="departamento"></label>
 
      </select>
      <select name="departamento" >
       <option selected="" value="" ><?php echo $res_consulta["Depto"]?></option>
      <?php    while($row1=mysql_fetch_array($res1))
	  		{?>
      <option value="<?php echo $row1['departamento']?>"> <?php echo utf8_encode($row1['departamento']);?></option>
      <?php } ?>
      </select></td>
    </tr>
    <tr>
      <td>Resguardante</td>
 
      <td><label for="resguardante"></label>
 
      </select>
      <select name="resguardante" >
       <option selected="" value="" ><?php echo $res_consulta["Resguardante"]?></option>
      <?php    while($row2=mysql_fetch_array($res2))
	  		{?>
      <option value="<?php echo $row2['resguardante']?>"> <?php echo utf8_encode($row2['resguardante']);?></option>
      <?php } ?>
      </select></td>
    </tr>
    <tr>
      <td colspan="2"><div align="right">
        <input type="submit" name="Actualizar" id="enviar" value="Actualizar" />
      </div></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

Segunda página, donde guardará los cambios. Tel_Modificar_Id_Guardar.php

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
<?php
 
require_once('Connections/final.php');
 
$id_new=$_POST['Id'];
$marca_new=$_POST['marca'];
$modelo_new=$_POST['modelo'];
$estado_new=$_POST['estado'];
$uso_new=$_POST['uso'];
$obser_new=$_POST['obser'];
$sede_new=$_POST["sede"];
$depto_new=$_POST['departamento'];
$resg_new=$_POST['resguardante'];
$sqlquery ="update tel_ip set Id='$id_new',
        								Marca='$marca_new',
										Modelo='$modelo_new',
										Estado='$estado_new',
										En_uso='$uso_new',
										Observaciones='$obser_new',
										Sede='$sede_new',
										Depto='$depto_new',
										Resguardante='$resg_new'
		where Id='$id_new'";
 
 
echo "Variable: ". $_REQUEST["$sqlquery"];
 
if($_POST['Actualizar']=="Actualizar")
 
{
    $sql=mysql_query($sqlquery,$final);
		echo "Los cambios han sido guardados. <a href='Tel_Consultar_Id.php'>Regresar</a>";
 
}
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder