In php devo lanciare questa query:
codice:
$query = "SELECT * FROM auto WHERE marca LIKE '$marca' AND modello LIKE '$modello' AND anno >= '$yearfrom' AND anno <= '$yearto' AND km >= '$mileagefrom' AND km <= '$mileageto' AND tipo_auto LIKE '$tipo_auto' AND tipo_carrozzeria LIKE '$tipo_carrozzeria' AND trasmissione LIKE '$trasmissione' AND carburante LIKE '$carburante' AND colore LIKE '$colore' AND potenza >= '$hpfrom' AND potenza <= '$hpto' AND prezzo >= '$eurofrom' AND prezzo <= '$euroto' ";
a cui verrà aggiunto
codice:
if ($climatizzatore == 's') $query = $query . "AND climatizzatore = 's' ";
if ($interni_pelle == 's') $query = $query . "AND interni_pelle = 's' ";
if ($alzacr_elettr == 's') $query = $query . "AND alzacr_elettr = 's' ";
if ($navigatore == 's') $query = $query . "AND navigatore = 's' ";
if ($tettuccio == 's') $query = $query . "AND tettuccio = 's' ";
if ($sedil_riscaldato == 's') $query = $query . "AND sedil_riscaldato = 's' ";
if ($cd == 's') $query = $query . "AND cd = 's' ";
if ($autoradio == 's') $query = $query . "AND autoradio = 's' ";
if ($abs == 's') $query = $query . "AND abs = 's' ";
if ($airbag == 's') $query = $query . "AND airbag = 's' ";
if ($airbag_pass == 's') $query = $query . "AND airbag_pass = 's' ";
if ($airbag_later == 's') $query = $query . "AND airbag_later = 's' ";
if ($chiusura_centr == 's') $query = $query . "AND chiusura_centr = 's' ";
if ($antifurto == 's') $query = $query . "AND antifurto = 's' ";
if ($controllo_trazione == 's') $query = $query . "AND controllo_trazione = 's' ";
if ($esp == 's') $query = $query . "AND esp = 's' ";
if ($trazione_integrale == 's') $query = $query . "AND trazione_integrale = 's' ";
if ($elaborato == 's') $query = $query . "AND elaborato = 's' ";
if ($cerchi_lega == 's') $query = $query . "AND cerchi_lega = 's' ";
if ($portapacchi == 's') $query = $query . "AND portapacchi = 's' ";
if ($fendinebbia == 's') $query = $query . "AND fendinebbia = 's' ";
if ($servosterzo == 's') $query = $query . "AND servosterzo = 's' ";
if ($garantito == 's') $query = $query . "AND garantito = 's' ";
if ($incidente == 's') $query = $query . "AND incidente = 's' ";
$query = $query . 'ORDER BY id DESC';
L'errore dove è? La query viene eseguita, ma non ritorna nulla! Invece dovrebbe essere equivalente a una "SELECT * FROM auto" !