el tipo de motor (motor, velero o ambos) para lo cual utilize 3 radiobuttons que al seleccionar me envian un entero que podria ser, dependiendo del tipo de motor, es decir si se elige "motor" me enviaba el entero "1" , si era "velero" me enviaba el entero "2" y asi...
Código :
<label> <input name="radio" type="radio" id="sail" value="1" checked="checked" />Motor</label> <label> <input type="radio" name="radio" id="both" value="2" />Sail</label> <label> <input type="radio" name="radio" id="both" value="3" />Both</label>
El otro parametro es la longitud de los barcos, para lo cual eran las variables "under 30, 30 a 45, 45 a 60 y over 60" y utilize la misma tecnica para de ponerle a "under 30" el entero "1" y así me enviaban número enteros.
Código :
<select name="length" id="length"> <option value="1">Under 30 mts.</option> <option value="2">30- 45 mts.</option> <option value="3">45- 60 mts.</option> <option value="4">Over 60 mts.</option> </select>
el otro parametro es los tripulantes, las variables son "6 -8, 10 -12, over 12" y usé también la misma técnica de los enteros.
Código :
<select name="guest" id="guest"> <option value="1">6 - 8 Guest</option> <option value="2">10 -12 Guest</option> <option value="3">Over 12</option> <option>All</option> </select>
y por último el precio, los cuales son "under 50,000","50000 a 100000"."100000 a 200000","200000 a 500000" y "over 500000" y usé también los enteros.
Código :
<select name="price" id="price"> <option value="1">Under 50,000 E</option> <option value="2">50,000 to 100,000 E</option> <option value="3">100,000 to 200,000 E</option> <option value="4">200,000 to 500,000 E</option> <option value="5">Over 500,000 E</option> </select>
y todo esto dentro de un formulario que me enviaba a un search.php
Contenido de search.php:
Código :
<?php $tipomotor=$_REQUEST['radio'];//se coje la variable de tipo de yacht( int ) $length=$_REQUEST['length'];//length ( int ) $guest=$_REQUEST['guest'];//coje guest del form( int ) $price =$_REQUEST['price'];// chapa el valor de los precios ( int ) $tabla = "yacht"; mysql_select_db("qed885",$searchcn); $result = mysql_query("select * from yacht where typemotorYacht=$tipomotor and idlengthYacht=$length and idguestYacht=$guest and idpriceYacht=$price order by nameYacht",$searchcn); ?> <ul class="trescol"> <?php if(mysql_num_rows($result)==0 ){ ?> <div id="result-search"><?php echo "Search item not found "?></div> <?php }else{ while($row=mysql_fetch_array($result)) { ?> <li> <div id="recuadro"> <div id="image"><a href="#" title="<?php echo $row[nameYacht] ?> - Moncada Hispania Yachts"><img src="<?php echo $row[imageYacht]?>" width="193" height="135" border="0" onclick="ventanaNueva('for-charter/moncada-hispania-yachts-<?php echo $row[idYacht]?>.php', 750, 600,'ventana<?php echo $row[idYacht]?>moncada','scrollbars=1')"/></a></div> <div id="recuadro-details"> <span class="name-yachts"><?php echo $row[nameYacht] ?></span></div> <div id="view-details"> <span class="deta-yachts"><img src="../images/row.jpg" /> <a href="#" onclick="ventanaNueva('for-charter/moncada-hispania-yachts-<?php echo $row[idYacht]?>.php', 750, 600,'ventana<?php echo $row[idYacht]?>moncada','scrollbars=1')">View Details</a></span> <span class="price-yachts"><?php echo $row[priceYacht]." "?></span> </div> </div> </li> <?php } } ?> </ul>
Bueno despues de esto el formulario funciona muy bien pero ahora hay que colocarle a cada combobox un "any o all" para cuando alguien por ejemplo quiera obtener una busqueda que no le intereze los tripulantes ni la longitud y solo el precio, en tripulantes eligan la varaiable "all" y en longitud tambien elijan "all" y solo el precio que sea "500000 a 100000", entonces que parametros pasaria cuando eligan esas variables, sabiendo que estan en enteros, y como seria la busqueda?
Esta es mi tabla.
Código :
CREATE TABLE `yacht` ( `idYacht` int(11) NOT NULL auto_increment, `nameYacht` varchar(45) NOT NULL, `lengthYacht` double(4,2) default NULL, `idlengthYacht` int(1) default '0', `guestYacht` int(3) NOT NULL, `idguestYacht` int(1) default '0', `buildYacht` int(4) NOT NULL, `imageYacht` varchar(60) NOT NULL, `priceYacht` decimal(10,2) default '0.00', `idpriceYacht` int(1) default '0', `typemotorYacht` int(1) default NULL, PRIMARY KEY (`idYacht`) ) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=latin1; INSERT INTO `yacht` VALUES (1,'Dionea',51.51,4,12,2,1962,'image/dionea.jpg',85000,2,2); INSERT INTO `yacht` VALUES (2,'D\'Angleterre II',41.21,3,10,2,1986,'image/dangleterre.jpg',78000,2,1); INSERT INTO `yacht` VALUES (3,'Ligaya',38.1,2,10,2,2002,'image/ligaya.jpg',95000,2,1); INSERT INTO `yacht` VALUES (4,'Metsuyan IV',36.02,2,10,2,2006,'image/metsuyan.jpg',95000,2,1); INSERT INTO `yacht` VALUES (5,'South Paw C',34.65,2,10,2,1977,'image/south-paw.jpg',54000,2,1); INSERT INTO `yacht` VALUES (6,'Anita',34.11,2,9,2,2006,'image/anita.jpg',95000,2,1); INSERT INTO `yacht` VALUES (7,'Clarity',31.6,2,8,1,2003,'image/clarity.jpg',60000,2,1); INSERT INTO `yacht` VALUES (8,'La Mascarade',30,1,8,1,1997,'image/mascarade.jpg',55000,2,2); INSERT INTO `yacht` VALUES (9,'Dreamster',28,1,8,1,2005,'image/dreamster.jpg',95000,2,1); INSERT INTO `yacht` VALUES (10,'Twisted ',24.97,1,8,1,2006,'image/twisted.jpg',42000,1,1); INSERT INTO `yacht` VALUES (11,'Samana',24,1,8,1,2006,'image/samana.jpg',42000,1,1); INSERT INTO `yacht` VALUES (12,'Nisida',18.8,1,8,1,2005,'image/nisida.jpg',18800,1,2); INSERT INTO `yacht` VALUES (13,'Jarami V',16.15,1,8,1,2006,'image/jarami.jpg',10000,1,2); INSERT INTO `yacht` VALUES (14,'AB Skipper',28.5,1,12,2,2003,'image/abskipper.jpg',0,1,1); INSERT INTO `yacht` VALUES (15,'Speedy Go',23.7,1,8,1,1984,'image/speedy-go.jpg',25000,1,1); INSERT INTO `yacht` VALUES (16,'Phoenix',35.7,2,9,2,2003,'image/phoenix.jpg',0,1,1); INSERT INTO `yacht` VALUES (17,'Mizar',26.5,1,8,1,1991,'image/mizar.jpg',0,1,1); INSERT INTO `yacht` VALUES (18,'New Flash',25.3,1,8,1,1990,'image/new-flash.jpg',0,1,1); INSERT INTO `yacht` VALUES (19,'Tuscan Sun',45,3,8,1,2006,'image/tuscan-sun.jpg',0,1,1); INSERT INTO `yacht` VALUES (20,'Aime Sea',35.11,2,8,1,1994,'image/aime-sea.jpg',0,1,1); INSERT INTO `yacht` VALUES (21,'Daydream',42.6,3,10,2,1997,'image/daydream.jpg',0,1,1); INSERT INTO `yacht` VALUES (22,'Catalyst of Fal',28.04,1,6,1,1995,'image/catalystoffal.jpg',0,1,3); INSERT INTO `yacht` VALUES (23,'Private Lives',36.58,2,8,1,2003,'image/private-lives.jpg',0,1,3); INSERT INTO `yacht` VALUES (24,'Happy Dolphin II',39.6,2,8,1,2004,'image/happy-dolphin.jpg',0,1,3); INSERT INTO `yacht` VALUES (25,'Orion',41.15,3,12,2,2004,'image/orion.jpg',0,1,1); INSERT INTO `yacht` VALUES (26,'Oneiro',52.7,4,12,2,2008,'image/oneiro.jpg',0,1,1); INSERT INTO `yacht` VALUES (27,'Kintaro',38.1,2,13,3,2005,'image/kintaro.jpg',0,1,1); INSERT INTO `yacht` VALUES (28,'Oceanos',49.29,3,14,3,2006,'image/oceanos.jpg',0,1,1); INSERT INTO `yacht` VALUES (29,'Opari',42,3,12,2,1997,'image/opari.jpg',0,1,1); INSERT INTO `yacht` VALUES (30,'Alexandros',21.16,1,8,1,2002,'image/alexandros.jpg',0,1,1); INSERT INTO `yacht` VALUES (31,'Odessa',50,4,10,2,2007,'image/odessa.jpg',0,1,1);
Donde idlengthYacht,idguestYacht,idpriceYacht son las agrupaciones de los barcos, es decir, agrupé a todos los barcos con la longitud menor a 30 metros y le puse como codigo 1 entonces de alli la búsqueda de la longitud en grupos y asi para los demas... entonces ahora me resulta problematico hacer una busqueda obviando los demas parametros y nos estamos volviendo locos

Este es el query de donde hago la busqueda..
Código :
select * from yacht where typemotorYacht=$tipomotor and idlengthYacht=$length and idguestYacht=$guest and idpriceYacht=$price order by nameYacht
A ver si se animan a echarme una mano, gracias
PD. aca el website: www.moncadahispania.com/yachts/