I have a form for real estate search and the first field should be able to return result based on 3 fields in the database. if by hood returns 0 then it should search by city else search by country
<?php
//search value
$location=$_GET["location"];
$type=$_GET['type'];
$price=$_GET['price'];
//==================================================================
#variables of search query
// User input
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$perPage = isset($_GET['per-page']) && $_GET['per-page'] <= 50 ? (int)$_GET['per-page'] : 6;
// Positioning
$start = ($page > 1) ? ($page * $perPage) - $perPage : 0;
// Query
$articles = "
SELECT SQL_CALC_FOUND_ROWS property_id, title,bedrooms,images,owner,status,posted_by,gsize,city,price,post_date,location,currency,poster_id
FROM properties where location='$location' or city='$location' or hood='$location'
";
if($type && !empty($type)){
$articles .= " AND property_type='$type'";
}
if($price && !empty($price)){
$articles .=" AND price <= '$price'";
}
$articles .= " order by post_date desc LIMIT {$start}, {$perPage}";
$articles=$dbc->query($articles);
$articles = $articles->fetchAll(PDO::FETCH_ASSOC);
?>