Login
or login with
query("SELECT id, make_name FROM car_makes ORDER BY make_name ASC")->fetch_all(MYSQLI_ASSOC); // Car Models (optionally filter by make later) $models = $conn->query("SELECT id, model_name, make_id FROM car_models ORDER BY model_name ASC")->fetch_all(MYSQLI_ASSOC); // Body types // Body types $bodies = $conn->query("SELECT DISTINCT car_type FROM cars_sale_inventory WHERE car_type IS NOT NULL AND car_type <> '' ORDER BY car_type ASC")->fetch_all(MYSQLI_ASSOC); // Min/max price/year $row = $conn->query("SELECT MIN(price) as min_price, MAX(price) as max_price, MIN(manufacture_year) as min_year, MAX(manufacture_year) as max_year FROM cars_sale_inventory")->fetch_assoc(); $minPrice = (int) $row['min_price']; $maxPrice = (int) $row['max_price']; $minYear = (int) $row['min_year']; $maxYear = (int) $row['max_year']; // Get filter values with defaults $make_id = isset($_GET['make_id']) ? intval($_GET['make_id']) : ''; $model_id = isset($_GET['model_id']) ? intval($_GET['model_id']) : ''; $body = isset($_GET['body']) ? $_GET['body'] : ''; $min_price = isset($_GET['min_price']) ? intval($_GET['min_price']) : $minPrice; $max_price = isset($_GET['max_price']) ? intval($_GET['max_price']) : $maxPrice; $min_year = isset($_GET['min_year']) ? intval($_GET['min_year']) : $minYear; $max_year = isset($_GET['max_year']) ? intval($_GET['max_year']) : $maxYear; // Filtering logic $where = []; if ($model_id) { $where[] = "car_model = $model_id"; } elseif ($make_id) { $model_ids = []; foreach ($models as $model) { if ($model['make_id'] == $make_id) $model_ids[] = $model['id']; } if (empty($model_ids)) $where[] = "0"; else $where[] = "car_model IN (" . implode(',', $model_ids) . ")"; } if ($body) $where[] = "car_type = '" . $conn->real_escape_string($body) . "'"; $where[] = "price BETWEEN $min_price AND $max_price"; $where[] = "manufacture_year BETWEEN $min_year AND $max_year"; if ($current_tab === 'New car') $where[] = "kilometers = 0"; elseif ($current_tab === 'Used car') $where[] = "kilometers > 0"; $where_sql = $where ? 'WHERE ' . implode(' AND ', $where) : ''; ?>
Explore our selection of high-quality, pre-owned vehicles. Our inventory includes top brands like Toyota, Mercedes, Honda, and more. Find the perfect used car for your needs.