$query = 'SELECT * WHERE ';
if(count($_GET) >1) {
foreach($_GET as $key => $value) {
$query .= $key.' = '.$value.' AND';
}
}
else {
foreach($_GET as $key => $value) {
$query .= $key.' = '.$value;
}
}
$filters = [];
foreach($_GET as $key => $value) {
$filters[] = $key . ' = ' . $value;
}
$filter = implode(" and ", $filters);