salve a tutti vi espongo il mio problema...
ho una tabella con 18 campi e devo effettuare una ricerca nelle varie righe con i valori che provengono da una form in cui potrò selezionare uno o piu valori tra cui due campi dove potrò inserire un valore minimo e un valore massimo.
io ho provato con like ma se ad esempio in un campo del form scrivo 25 e 25 si trova sia nel campo A che nel campo D della tabella mi estrapola sia la riga del campo A che del campo D faccio un esempio pratico
tabella prova campi a, b, c, d
nella riga con id 1 ho il valore 25 in a e nella riga con id 11 ho il valore 25 in d con la seguente query mi stampa sia la riga 1 che la riga 11 ma in realtà io ho passato da form a=25 e d=33
in modo da paura ho fatto per tre valori così ma per me è assurdo...
riuscire a combinare 18 campi
if ($regione!="tutte" and $tipo!="tutte" and $categoria=="tutte"){$primo="where regione='$regione' and tipo like '%$tipo%'";}else{$primo="";}
if ($regione=="tutte" and $tipo!="tutte" and $categoria=="tutte"){$secondo="where tipo like '%$tipo%'";}else{$secondo="";}
if ($regione!="tutte" and $tipo=="tutte" and $categoria=="tutte"){$terzo="where regione='$regione'";}else{$terzo="";}
if ($regione!="tutte" and $categoria!="tutte" and $tipo=="tutte"){$quarto="where regione='$regione' and categoria='$categoria'";}else{$quarto="";}
if ($tipo!="tutte" and $categoria!="tutte" and $regione=="tutte"){$quinto="where tipo like '%$tipo%' and categoria='$categoria'";}else{$quinto="";}
if ($tipo!="tutte" and $categoria!="tutte" and $regione!="tutte"){$sesto="where tipo like '%$tipo%' and categoria='$categoria' and regione='$regione'";}else{$sesto="";}
if ($regione=="tutte" and $tipo=="tutte" and $categoria!="tutte"){$settimo="where categoria='$categoria'";}else{$settimo="";}
sostituendo nella query
$queryi="select id from prova $primo $secondo $terzo $quarto $quinto $sesto $settimo order by id ";
e per i valori minimo e massimo non so come fare il confronto
spero per me di essere stato il più chiaro possibile
grazie e ciao a tutti![]()