Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/11/2012, 20:00
mariohr61
 
Fecha de Ingreso: octubre-2012
Mensajes: 4
Antigüedad: 11 años, 6 meses
Puntos: 0
Al ejecutar una consulta no me devuelve resultados

Hola amigos,en primer lugar, los felicito por la ayuda que brindan.
pasando a mi problema, tengo un formulario desde el cual mando unas variables a un segundo formulario para ejecutar una consulta mediante enlace:
<td style="width: 65px"><a href="cons_torres.php?cod_sitio= <?php echo $fila[id_sitio];?>&sitio=<?php echo $fila[sitio];?>&tipo=<?php echo $fila[tipo];?>">Torres</a></td>

En el segundo formulario, asigno los parametros recibidos a variables;
$cons_torre=$_REQUEST["cod_sitio"];
$sitio=$_REQUEST["sitio"];
$tipo=$_REQUEST["tipo"];

Aplico un echo a las variables para ver si estoy recibiendo los parametros y si me muestra los parametros recibidos.

a continuacion aplico la consulta:
$conexion = mysql_connect('localhost','root',''); //Realiza la conexion
mysql_select_db("teleco",$conexion)
or die("Problemas al conectar a la base de datos");

$reg_torre=mysql_query("SELECT id_sitio,id_torre,tipo,modelo,altura,status FROM torres WHERE id_sitio = '".$cons_torre."';",$conexion) or
die("Problemas al ejecutar la consulta:".mysql_error();
a continuacion genero la tabla para m ostrar resultados:

$num_registros=mysql_num_rows($reg_torre);

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Busqueda de torres</title>
</head>

<body>

<center>
<table width="100%" border="0">
<tr>
<td><div align="center"><span class="style1"><strong>SITIO: </strong><?php echo $tipo; echo $sitio;?> </span></div></td>
</tr>
<td><div align="center"><span class="style1"><strong>LISTADO DE TORRES</strong></span></div></td>
<tr>
<td><form id="frm_torres" name="frm_torres" method="GET" action="cons_torres.php">

Torres encontradas: <?php echo $num_registros;?>
</form></td>
</tr>
<tr>
<td>
</td>

</tr>
<tr>
<td><a href="cons_torres.php">continuar</a></td>
</tr>


</table>
<td><table border="1" cellspacing="0" style="width: 100%" cellpadding="0">
<tr>
<td width="75" height="39" bgcolor="#99FFFF"><div align="center">ID TORRE</div></td>
<td width="75" bgcolor="#99FFFF"><div align="center">TIPO</div></td>
<td width="75" bgcolor="#99FFFF"><div align="center">MODELO</div></td>
<td width="75" bgcolor="#99FFFF"><div align="center">ALTURA</div></td>
<td width="75" bgcolor="#99FFFF"><div align="center">STATUS</div></td>
<td width="75" bgcolor="#99FFFF"><div align="center">ANTENAS</div></td>
</tr>
<tr>
<?php

while ($fila=mysql_fetch_array($reg_torre))
{
?>

<tr >
<td style="width: 65px"> <?php echo $fila[id_torre];?></td>
<td style="width: 65px"> <?php echo $fila[tipo];?></td>
<td style="width: 65px"> <?php echo $fila[modelo];?></td>
<td style="width: 65px"> <?php echo $fila[altura];?></td>
<td style="width: 65px"> <?php echo $fila[status];?></td>
<td style="width: 65px"><a href="cons_antenas.php?cod_torre= <?php echo $fila[id_torre];?>&sitio=<?php echo $fila[sitio];?>">Antenas</a></td>
</tr>

<?php
}
?>
</tr>
</table></td>


</body>
</html>

Peeeero al llamar a esta pagina desde la primera no me muestra ningun resultado en la tabla
si yo asigno un valor a la variable $cons_torre = "C066"; en forma directa,y ejecuto la consulta, si me devuelve los valores esperados en la tabla.
no se que estoy omitiendo.
Soy novato en php y dese ya agradesco su ayuda.
mil gracias.
Saludos cordiales.