Foros del Web » Programando para Internet » PHP »

Select no me selecciona

Estas en el tema de Select no me selecciona en el foro de PHP en Foros del Web. Hola , Tengo este código y cuando se ejecuta No me da ningún fallo, llega hasta el final, (ninguna habitación disponible) Pero no me da ...
  #1 (permalink)  
Antiguo 22/02/2011, 11:40
 
Fecha de Ingreso: diciembre-2010
Mensajes: 8
Antigüedad: 13 años, 4 meses
Puntos: 0
Select no me selecciona

Hola ,
Tengo este código y cuando se ejecuta No me da ningún fallo, llega hasta el final, (ninguna habitación disponible)
Pero no me da ningún resultado
¿Dónde puede estar el fallo?
Código PHP:
<?php
include 'headerFooter.php';
include 
'validar_popu.php';
include 
'validar_datos.php';
include 
'conexion.php';

/* la página web comienza aquí */
if($_POST["cliente"] > ""
{
    
writeHeader("Confirmation");
        
/* página 4 */
        
    
footer();
} else if(
$_POST["id_habitacion"] > ""

    
writeHeader("Reserve a Room, Reserve un Espacio ");
        
/* página 3 */
        
    
footer();
} else 

    
writeHeader("");

    
/* Forma de búsqueda */
    
    
$fecha_entrada=validDate($_POST["fecha_entradadaYear"] . "-" $_POST["fecha_entradaMonth"] . "-" $_POST["fecha_entradaDay"]);
    
$fecha_salida=validDate($_POST["fecha_salidaYear"] . "-" $_POST["fecha_salidaMonth"] . "-" $_POST["fecha_salidaDay"]);
    
    
    


    print <<<EOT
    
    <center>
    <form action="bnb.php" method="post" name="reservation">
    <table border="1">
        <tr>
            <td>adultos</td><td>entrada</td><td>salida</td>
        </tr>
        <tr>
            <td><select name="adultos">
EOT;
    for(
$i 1$i 11$i++)
    {
        if (
$_POST["adultos"] == $i)
        {
            print 
"<option value='$i' SELECTED>$i</option>\n";
        } else {
            print 
"<option value='$i'>$i</option>\n";
        }
    }
    print 
"</select></td>\n<td>";
    print 
datePopups($fecha_entradafecha_entrada);
    print 
"</td><td>";
    print 
datePopups($fecha_salidafecha_salida);
    print <<<EOT
        </td>
            </tr>
    </table><br>
    <input type="submit" value="disponivilidad"></form>
    </center>
    
EOT;


    if(
$_POST["adultos"] > ""
    {
        




$myQuery "SELECT habitacion.id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
    
$myQuery =     $myQuery " FROM habitacion, Reserva ";
    
$myQuery $myQuery " WHERE habitacion.id_habitacion = Reserva.id_habitacion ";
    
$myQuery $myQuery " AND ocupacion_maxima >= " $_POST["adultos"] ;
    
$myQuery $myQuery " AND fecha_entrada >= '" $_POST["fecha_entrada"] . "' ";
    
$myQuery $myQuery " AND fecha_salida <= '" $_POST["fecha_salida"] . "' ";
    
$myQuery $myQuery " GROUP BY id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
    
$myQuery $myQuery " HAVING count(*) > 0 ";
    
$myQuery $myQuery " ORDER BY ocupacion_maxima asc, tarifa desc ";

    


    


$resultado mysql_query($myQuery$link)
      or die(
"error "); 
  
    if (
mysql_num_rows($resultado) > 0)
    {
        print 
"<center><br><br>Resultados<BR><table border=1 width=90%><tr><th></th><th>Nombre</th><th>Descricion</th><th>Maxima<br>Ocupacion</th><th>tarifa</th></tr>\n";
        
        while (
$row mysql_fetch_array($resultado))
        { 
            print 
"<tr><td><A HREF='reservation.php?id_habitacion=" $row["id"] . "'&fecha_entrada=" $_POST["fecha_entrada"] . "&fecha_salida=" $_POST["fecha_salida"] . ">Reservas</td><td>" $row["nombre"] . "</A></td><td>" $row["descricion"] . "</td><td>" $row["ocupacion_maxima"] . "</td><td>" $row["tarifa"] . "</td></tr>";
        } 
        print 
"</table></center><br>";
        } else {
            

print 
"<center> ningúna habitacion disponible.</center><br>";


    }
    
  
mysql_close($link);

    }
    
footer();
}

?>
  #2 (permalink)  
Antiguo 22/02/2011, 11:46
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 4 meses
Puntos: 51
Respuesta: Select no me selecciona

Ejecutaste la query en un phpmyadmin para ver si da resultados?
  #3 (permalink)  
Antiguo 22/02/2011, 11:46
Avatar de bUllan9ebrio  
Fecha de Ingreso: enero-2011
Ubicación: Chile
Mensajes: 1.128
Antigüedad: 13 años, 2 meses
Puntos: 128
Respuesta: Select no me selecciona

Compa hace esto :

Código PHP:
Ver original
  1. $myQuery = "SELECT habitacion.id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
  2.     $myQuery =     $myQuery . " FROM habitacion, Reserva ";
  3.     $myQuery = $myQuery . " WHERE habitacion.id_habitacion = Reserva.id_habitacion ";
  4.     $myQuery = $myQuery . " AND ocupacion_maxima >= " . $_POST["adultos"] ;
  5.     $myQuery = $myQuery . " AND fecha_entrada >= '" . $_POST["fecha_entrada"] . "' ";
  6.     $myQuery = $myQuery . " AND fecha_salida <= '" . $_POST["fecha_salida"] . "' ";
  7.     $myQuery = $myQuery . " GROUP BY id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
  8.     $myQuery = $myQuery . " HAVING count(*) > 0 ";
  9.     $myQuery = $myQuery . " ORDER BY ocupacion_maxima asc, tarifa desc ";
  10.  
  11. echo $myQuery;

Luego pruebalo directo en la base de datos
  #4 (permalink)  
Antiguo 22/02/2011, 11:50
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 4 meses
Puntos: 51
Respuesta: Select no me selecciona

Cita:
Iniciado por bUllan9ebrio Ver Mensaje
Compa hace esto :

Código PHP:
Ver original
  1. $myQuery = "SELECT habitacion.id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
  2.     $myQuery =     $myQuery . " FROM habitacion, Reserva ";
  3.     $myQuery = $myQuery . " WHERE habitacion.id_habitacion = Reserva.id_habitacion ";
  4.     $myQuery = $myQuery . " AND ocupacion_maxima >= " . $_POST["adultos"] ;
  5.     $myQuery = $myQuery . " AND fecha_entrada >= '" . $_POST["fecha_entrada"] . "' ";
  6.     $myQuery = $myQuery . " AND fecha_salida <= '" . $_POST["fecha_salida"] . "' ";
  7.     $myQuery = $myQuery . " GROUP BY id_habitacion, nombre, descricion, ocupacion_maxima, tarifa ";
  8.     $myQuery = $myQuery . " HAVING count(*) > 0 ";
  9.     $myQuery = $myQuery . " ORDER BY ocupacion_maxima asc, tarifa desc ";
  10.  
  11. echo $myQuery;

Luego pruebalo directo en la base de datos
Sos mi eco? XDD

PD: bromita :P
  #5 (permalink)  
Antiguo 22/02/2011, 11:52
Avatar de bUllan9ebrio  
Fecha de Ingreso: enero-2011
Ubicación: Chile
Mensajes: 1.128
Antigüedad: 13 años, 2 meses
Puntos: 128
Respuesta: Select no me selecciona

jajajjajaja no para nada, pero resulta que a veces no entienden bien cuando uno usa termino mas "generales" por decirlo de algun modo
  #6 (permalink)  
Antiguo 22/02/2011, 12:04
Colaborador
 
Fecha de Ingreso: mayo-2008
Ubicación: $MX['VZ']['Xalapa']
Mensajes: 3.005
Antigüedad: 15 años, 11 meses
Puntos: 528
Respuesta: Select no me selecciona

sólo como comentario
no es necesario hacer:
$myQuery = $myQuery . " FROM habitacion, Reserva ";
cuando puedes hacer:
$myQuery.= " FROM habitacion, Reserva ";
  #7 (permalink)  
Antiguo 22/02/2011, 12:57
 
Fecha de Ingreso: diciembre-2010
Mensajes: 8
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Select no me selecciona

lo he ejecutado y me sale esto

FROM habitacion, Reserva WHERE habitacion.id_habitacion = Reserva.id_habitacion AND ocupacion_maxima >= 10 AND fecha_entrada >= '' AND fecha_salida <= '' GROUP BY id_habitacion, nombre, descricion, ocupacion_maxima, tarifa HAVING count(*) > 0 ORDER BY ocupacion_maxima asc, tarifa desc
  #8 (permalink)  
Antiguo 22/02/2011, 13:03
Avatar de bUllan9ebrio  
Fecha de Ingreso: enero-2011
Ubicación: Chile
Mensajes: 1.128
Antigüedad: 13 años, 2 meses
Puntos: 128
Respuesta: Select no me selecciona

AHORA ejecutala direto en tu motor de base de datos
  #9 (permalink)  
Antiguo 22/02/2011, 13:08
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 4 meses
Puntos: 51
Respuesta: Select no me selecciona

Es obvio que tenés errores en tu sql, simplemente con ver las fechas vacías difcilmente te traiga algo.
  #10 (permalink)  
Antiguo 22/02/2011, 15:48
 
Fecha de Ingreso: diciembre-2010
Mensajes: 8
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Select no me selecciona

gracias, lla funciona un par de gomillas de mas
  #11 (permalink)  
Antiguo 26/02/2011, 01:43
 
Fecha de Ingreso: diciembre-2010
Mensajes: 8
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Select no me selecciona

Hola,
Buenas, mira vuelvo con este tema porque en les quite dos coma aquí
Código PHP:
Ver original
  1. [PHP$myQuery = $myQuery . " AND entrada >= " .  $_POST['$entrada'] . "' ";
  2.     $myQuery = $myQuery . " AND salida <=  " .  $_POST["$salida"] . "' ";][/PHP]

Y me funciona la pagina, a medías, me muestra las habitaciones, y dependiendo de las personas me muestra el tipo de habitación, esto va bien .pero como me dice walterdevel lo que me está fallando es la fecha de entrada y de salida haber si me pudierais echar una mano gracias
  #12 (permalink)  
Antiguo 26/02/2011, 02:42
Avatar de s00rk  
Fecha de Ingreso: octubre-2010
Ubicación: Mexico
Mensajes: 238
Antigüedad: 13 años, 5 meses
Puntos: 48
Respuesta: Select no me selecciona

Cita:
Iniciado por elsevilla Ver Mensaje
Hola,
Buenas, mira vuelvo con este tema porque en les quite dos coma aquí
Código PHP:
Ver original
  1. [PHP$myQuery = $myQuery . " AND entrada >= " .  $_POST['$entrada'] . "' ";
  2.     $myQuery = $myQuery . " AND salida <=  " .  $_POST["$salida"] . "' ";][/PHP]

Y me funciona la pagina, a medías, me muestra las habitaciones, y dependiendo de las personas me muestra el tipo de habitación, esto va bien .pero como me dice walterdevel lo que me está fallando es la fecha de entrada y de salida haber si me pudierais echar una mano gracias
Si asi tienes tu codigo ahi esta mal hecho, deveria ser asi no?

Código PHP:
Ver original
  1. $myQuery = $myQuery . " AND entrada >= '" .  $_POST['entrada'] . "' ";
  2.     $myQuery = $myQuery . " AND salida <=  '" .  $_POST['salida'] . "' ";
  #13 (permalink)  
Antiguo 26/02/2011, 03:34
 
Fecha de Ingreso: diciembre-2010
Mensajes: 8
Antigüedad: 13 años, 4 meses
Puntos: 0
Respuesta: Select no me selecciona

Hola s00rk,
Perdona se me han colado esos php al pricipio y el fina.
Como tú me dice lo tenía puesto antes, pero no me funciona, esa coma que me estas poniendo de mas, que no digo que sobre, me corre la pagina hasta el final (ninguna habitación disponible)cuándo debería mostrarme las habitaciones, y tampoco de esa manera me enseña las fechas.

Etiquetas: select
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 14:24.