Codice PHP:
$where="";
if(isset($_POST[auto]))
{
$where.=" auto1='$_POST[auto]' or ";
$where.=" auto2='$_POST[auto]' or ";
$where.=" auto3='$_POST[auto]' ";
}
if(isset($_POST[auto1]))
{
if($where!="")
{
$where.=" or "
}
$where.=" auto1='$_POST[auto1]' or ";
$where.=" auto2='$_POST[auto1]' or ";
$where.=" auto3='$_POST[auto1]' ";
}
if(isset($_POST[auto2]))
{
if($where!="")
{
$where.=" or "
}
$where.=" auto1='$_POST[auto2]' or ";
$where.=" auto2='$_POST[auto2]' or ";
$where.=" auto3='$_POST[auto2]' ";
}
$query1 = "SELECT * FROM tabella_auto WHERE ".$where;
ma se la logica della query è sbagliata va cambiato anche questo