
Problema al buscar en una tabla con datos, ayuda por favor
Publicado por Carlos (5 intervenciones) el 04/05/2015 12:38:40
Buenos dias necesito ayuda porque estoy un poco perdido y no veo cual es el fallo.
Tengo una tabla en la que estoy intentando realizar una búsqueda entre dos fechas y un nombre.
La primera prueba es la búsqueda entre dos fechas.
Tengo un formulario con el siguiente código:
El codigo de buscarhoteles.php es:
Al ejecutar la busqueda me devuelve el siguiente error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /localhost/buscarhoteles.php
por ahora estoy intentando buscar entre fechas, pero me gustaria añadir el nombre del hotel. Me gustaría buscar el nombre del hotel en una columna y entre dos fechas.
Un saludo
Tengo una tabla en la que estoy intentando realizar una búsqueda entre dos fechas y un nombre.
La primera prueba es la búsqueda entre dos fechas.
Tengo un formulario con el siguiente código:
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<form action="buscarhoteles.php" method="post">
<br><br>Seleccionar hotel<p></p>
<select name="hoteles">
<option value="h1">Las Costas</option>
<option value="h2">Floresta</option>
<option value="h3">Lanzarote Village</option>
<option value="h4"</option>
<option value="h5"</option>
<option value="h6"</option>
<option value="h7"</option>
<option value="h8"</option>
<option value="h9"</option>
<option value="h10">Los Zocos</option>
</select>
<p></p>
Seleccionar fecha y hora <input type="datetime-local" name="fechayhora1"><br>
Seleccionar fecha y hora <input type="datetime-local" name="fechayhora2"><br>
<input type="Submit" name="enviar" value="Aceptar y enviar">
</form>
</body>
</html>
El codigo de buscarhoteles.php es:
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
<html>
<body>
<?php
$link = mysql_connect("xxxxxxxxxxxxxxxxxxxxx","xxxxxxxx","xxxxxxxxxxxxx");
mysql_select_db("xy",$link);
$fecha1=$_POST["fechayhora1"];
$fecha2=$_POST["fechayhora2"];
$nombrehotel=$_POST["hoteles"];
//busqueda por nombre y dos fechas
$consulta_mysql="SELECT * FROM parametroshoteles WHERE datex BETWEEN $fecha1 AND $fecha2 ORDER BY datex ASC";
$resultado_consulta_mysql=mysql_query($consulta_mysql,$link);
while($registro=mysql_fetch_array($resultado_consulta_mysql)){
echo $registro['hotel']."
";
}
?>
<A HREF="menu.html" TARGET="_BLANK"><p>Introducir mas datos</p>
</body>
</html>
Al ejecutar la busqueda me devuelve el siguiente error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /localhost/buscarhoteles.php
por ahora estoy intentando buscar entre fechas, pero me gustaria añadir el nombre del hotel. Me gustaría buscar el nombre del hotel en una columna y entre dos fechas.
Un saludo
Valora esta pregunta


0