connect_error) { die("Connection failed: " . $conn->connect_error); } $conn->set_charset("utf8mb4"); // Pagination $limit = 9; $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $search = isset($_GET['search']) ? trim($_GET['search']) : ''; $cc_filter = isset($_GET['cc']) ? trim($_GET['cc']) : ''; $price_filter = isset($_GET['price']) ? trim($_GET['price']) : ''; $start = ($page - 1) * $limit; // Build query $where_conditions = ["m.status=1"]; $params = []; $types = ""; if (!empty($search)) { $where_conditions[] = "(m.moped_name LIKE ? OR m.moped_headline LIKE ? OR m.moped_description LIKE ?)"; $search_param = "%$search%"; $params = array_merge($params, [$search_param, $search_param, $search_param]); $types .= "sss"; } if (!empty($cc_filter)) { switch($cc_filter) { case 'under-70': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) < 70"; break; case '70-100': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) BETWEEN 70 AND 100"; break; case 'above-100': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) > 100"; break; } } if (!empty($price_filter)) { switch($price_filter) { case 'under-40k': $where_conditions[] = "(SELECT MIN(price) FROM moped_colors WHERE moped_id = m.moped_id) < 40000"; break; case '40-50k': $where_conditions[] = "(SELECT MIN(price) FROM moped_colors WHERE moped_id = m.moped_id) BETWEEN 40000 AND 50000"; break; case '50-60k': $where_conditions[] = "(SELECT MIN(price) FROM moped_colors WHERE moped_id = m.moped_id) BETWEEN 50000 AND 60000"; break; case 'above-60k': $where_conditions[] = "(SELECT MIN(price) FROM moped_colors WHERE moped_id = m.moped_id) > 60000"; break; } } // Count total $count_query = "SELECT COUNT(DISTINCT m.moped_id) as total FROM mopeds m WHERE " . implode(" AND ", $where_conditions); $stmt = $conn->prepare($count_query); if (!empty($params)) { $stmt->bind_param($types, ...$params); } $stmt->execute(); $total = $stmt->get_result()->fetch_assoc()['total']; $stmt->close(); $pages = max(1, ceil($total / $limit)); // Get mopeds for current page $query = "SELECT m.*, (SELECT MIN(price) FROM moped_colors WHERE moped_id = m.moped_id) as min_price, (SELECT MAX(price) FROM moped_colors WHERE moped_id = m.moped_id) as max_price, (SELECT COUNT(*) FROM moped_colors WHERE moped_id = m.moped_id) as color_count, (SELECT mc.color_code FROM moped_colors mc WHERE mc.moped_id = m.moped_id LIMIT 1) as first_color, (SELECT mi.image_path FROM moped_colors mc LEFT JOIN moped_images mi ON mc.color_id = mi.color_id AND mi.is_primary = 1 WHERE mc.moped_id = m.moped_id LIMIT 1) as primary_image FROM mopeds m WHERE " . implode(" AND ", $where_conditions) . " ORDER BY m.moped_id DESC LIMIT ?, ?"; $stmt = $conn->prepare($query); if (!empty($params)) { $stmt->bind_param($types . "ii", ...array_merge($params, [$start, $limit])); } else { $stmt->bind_param("ii", $start, $limit); } $stmt->execute(); $result = $stmt->get_result(); $mopeds = []; if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // Get all colors for this moped $color_sql = "SELECT color_name, color_code, price FROM moped_colors WHERE moped_id = ? ORDER BY price"; $color_stmt = $conn->prepare($color_sql); $color_stmt->bind_param("i", $row['moped_id']); $color_stmt->execute(); $color_result = $color_stmt->get_result(); $row['colors'] = []; while ($color = $color_result->fetch_assoc()) { $row['colors'][] = $color; } $color_stmt->close(); $mopeds[] = $row; } } $stmt->close(); // Get filter options $cc_ranges = [ 'under-70' => 'Under 70cc', '70-100' => '70cc - 100cc', 'above-100' => 'Above 100cc' ]; $price_ranges = [ 'under-40k' => 'Under ₹40,000', '40-50k' => '₹40,000 - ₹50,000', '50-60k' => '₹50,000 - ₹60,000', 'above-60k' => 'Above ₹60,000' ]; // WhatsApp number $whatsapp_number = "919345994249"; ?>
Discover our range of fuel-efficient mopeds perfect for daily commuting and work. Low maintenance, high mileage.
Moped Models
Avg. Mileage
Maintenance
Happy Riders
We couldn't find any mopeds matching your search criteria. Try adjusting your filters.
Experience the fuel efficiency and reliability of our mopeds firsthand.
Schedule Test Ride