Foros del Web » Programando para Internet » PHP »

ayuda con este script !!!!

Estas en el tema de ayuda con este script !!!! en el foro de PHP en Foros del Web. yo utilizo este script para buscar en mi base de datos resultados de tipo hospedaje, el cual me funciona bien, pero cuando le hago click ...
  #1 (permalink)  
Antiguo 15/09/2003, 13:38
Avatar de el cirujano  
Fecha de Ingreso: mayo-2003
Ubicación: Frente al PC
Mensajes: 609
Antigüedad: 20 años, 11 meses
Puntos: 3
ayuda con este script !!!!

yo utilizo este script para buscar en mi base de datos resultados de tipo hospedaje, el cual me funciona bien, pero cuando le hago click en el enlace "<a href=listahotel.php?id=$id>" no me hace el enlace correcto para que me de el resultado correcto, ejemplo: tengro tres hoteles registrados, CAMINO REAL, GUADALUPE, PRINCESA, y cuando hago click para que me de el resultado de GUADALUPE siempre me da el ultimo registro ingresado, en este caso PRINCESA. que puedo hacer, por los momentos voy a dejarles los dos script que uso.....

listar.php (me busca los resultado y muestra solo los nombres organizandolos por provincia, nombre del htel y categoria.....)

<head>
<link rel="stylesheet" type="text/css" href="style/style.css">
<title>.: GuiaViajera.com :.</title>
</head>

<body bgcolor="#e6e9d8" text="#333300" link="#333300" vlink="#333300" alink="#333300">

<?
include("conexion.php");
$conexion= conectar();
$sql = mysql_query("SELECT * FROM hospedaje WHERE tipo LIKE tipo ORDER BY estado,hotel,categoria DESC ",$conexion);

$estado = "estado";

if (mysql_num_rows($sql)>0){

while ($row = mysql_fetch_array($sql)){
$i++;
$estado = $row["estado"];
$hotel = $row["hotel"];
$ciudad = $row["ciudad"];
$id = $row["id"];
$categoria = $row["categoria"];
if (empty($categoria)){
$categoria = "pix.gif";
}
?>
<?
echo "<table width=699 border=0 align=center height=21 bgcolor=#e6e9d8>";

if ($estado <> $provincia){
echo "<tr><td><tt><img src=images/$categoria> <b><a href='listahotel.php?id=$id'>$hotel</a> - <font color='#336699'>$ciudad-$estado.
</font></b></tt></td></tr>";
$estado=$estado;
}else{
$estado=$estado;}
}
echo "</table>";
}else{
echo "<tt><b>Su búsqueda - <font color='#FFCC33'>$tipo</font> - no produjo ningún documento.<br>";
echo "<br>";
echo "<tt><b>Sugerencias:<br>";
echo "<br>";
echo "<tt><b>- Asegúrese de que todas las palabras estén escritas correctamente.<br>";
echo "<tt><b>- Intente usar otras palabras.<br>";
echo "<tt><b>- Intente usar palabras más generales.<br>";
echo "<tt><b>- Intente usar menos palabras.<br>";
}

mysql_free_result($sql);
mysql_close($conexion);

?>



listahotel.php (me tiene que dar toda la información acerca del hotel seleccionado en la pagina anterior...)

<?php
include ("conexion.php");
$conexion= conectar();

$sql=mysql_query("SELECT * from hospedaje where 'id' like '%$id%'",$conexion);

while ($row = mysql_fetch_array($sql)){

$fachada = $row["fachada"];
if (empty($fachada)){
$fachada = "pix.gif";
}
$hotel = $row["hotel"];
$direccion = $row["direccion"];
$ciudad = $row["ciudad"];
$estado = $row["estado"];
$telefono = $row["telefono"];
$email = $row["email"];
if (empty($email)){
$email = "No tienen Email";
}
$url = $row["url"];
if (empty($url)){
$url = "No tienen URL";
}
$categoria = $row["categoria"];
if (empty($categoria)){
$categoria = "pix.gif";
}
$resena = $row["resena"];
$ubicacion = $row["ubicacion"];
$servicio = $row["servicio"];
$sucursales = $row["sucursales"];
$habitacion = $row["habitacion"];
$precio = $row["precio"];
$imagen = $row["imagen"];
if (empty($imagen)){
$imagen = "pix.gif";
}
$habitacion1 = $row["habitacion1"];
$precio1 = $row["precio1"];
$imagen1 = $row["imagen1"];
if (empty($imagen1)){
$imagen1 = "pix.gif";
}
$habitacion2 = $row["habitacion2"];
$precio2 = $row["precio2"];
$imagen2 = $row["imagen2"];
if (empty($imagen2)){
$imagen2 = "pix.gif";
}
$habitacion3 = $row["habitacion3"];
$precio3 = $row["precio3"];
$imagen3 = $row["imagen3"];
if (empty($imagen3)){
$imagen3 = "pix.gif";
}
$habitacion4 = $row["habitacion4"];
$precio4 = $row["precio4"];
$imagen4 = $row["imagen4"];
if (empty($imagen4)){
$imagen4 = "pix.gif";
}
$habitacion5 = $row["habitacion5"];
$precio5 = $row["precio5"];
$imagen5 = $row["imagen5"];
if (empty($imagen5)){
$imagen5 = "pix.gif";
}
$habitacion6 = $row["habitacion6"];
$precio6 = $row["precio6"];
$imagen6 = $row["imagen6"];
if (empty($imagen6)){
$imagen6 = "pix.gif";
}
$habitacion7 = $row["habitacion7"];
$precio7 = $row["precio7"];
$imagen7 = $row["imagen7"];
if (empty($imagen7)){
$imagen7 = "pix.gif";
}
$habitacion8 = $row["habitacion8"];
$precio8 = $row["precio8"];
$imagen8 = $row["imagen8"];
if (empty($imagen8)){
$imagen8 = "pix.gif";
}
$habitacion9 = $row["habitacion9"];
$precio9 = $row["precio9"];
$imagen9 = $row["imagen9"];
if (empty($imagen9)){
$imagen9 = "pix.gif";
}
$habitacion0 = $row["habitacion0"];
$precio0 = $row["precio0"];
$imagen0 = $row["imagen0"];
if (empty($imagen0)){
$imagen0 = "pix.gif";
}
$otro = $row["otro"];


}

?>
<head>
<link rel="stylesheet" type="text/css" href="style/style.css">
<title>.: <? echo ("$hotel");?> - GuiaViajera.com :.</title>
</head>

<body bgcolor="#e6e9d8" text="#333300" link="#333300" vlink="#333300" alink="#333300">


<!-- aqui contruyo una tabla para mostrar la información del hotel-->
<p>
<?

mysql_free_result($sql);
mysql_close($conexion);

?></p>
</body>



gracias a todos..
__________________
CSS2 + AJAX + PHP + MySQL, una mezcla sin competencia!!!!!!
  #2 (permalink)  
Antiguo 15/09/2003, 13:54
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
Hola,

Cambia en el SQL de la segunda pagina el

where 'id' like '%$id%'

por

where id='$id'

Ya que solo existe un registro con ese id, ¿verdad?

Saludos.
__________________
Josemi

Aprendiz de mucho, maestro de poco.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:17.