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']) : ''; $start = ($page - 1) * $limit; // Build query $where_conditions = ["s.status=1"]; $params = []; $types = ""; if (!empty($search)) { $where_conditions[] = "(s.scooter_name LIKE ? OR s.scooter_headline LIKE ? OR s.scooter_description LIKE ?)"; $search_param = "%$search%"; $params = array_merge($params, [$search_param, $search_param, $search_param]); $types .= "sss"; } // Count total $count_query = "SELECT COUNT(DISTINCT s.scooter_id) as total FROM scooters s 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 scooters for current page with colors and images $query = "SELECT s.*, (SELECT MIN(price) FROM scooter_colors WHERE scooter_id = s.scooter_id) as min_price, (SELECT MAX(price) FROM scooter_colors WHERE scooter_id = s.scooter_id) as max_price, (SELECT COUNT(*) FROM scooter_colors WHERE scooter_id = s.scooter_id) as color_count, (SELECT sc.color_code FROM scooter_colors sc WHERE sc.scooter_id = s.scooter_id LIMIT 1) as first_color, (SELECT si.image_path FROM scooter_colors sc LEFT JOIN scooter_images si ON sc.color_id = si.color_id AND si.is_primary = 1 WHERE sc.scooter_id = s.scooter_id LIMIT 1) as primary_image FROM scooters s WHERE " . implode(" AND ", $where_conditions) . " ORDER BY s.scooter_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(); $scooters = []; if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // Get all colors for this scooter $color_sql = "SELECT color_name, color_code, price FROM scooter_colors WHERE scooter_id = ? ORDER BY price"; $color_stmt = $conn->prepare($color_sql); $color_stmt->bind_param("i", $row['scooter_id']); $color_stmt->execute(); $color_result = $color_stmt->get_result(); $row['colors'] = []; while ($color = $color_result->fetch_assoc()) { $row['colors'][] = $color; } $color_stmt->close(); $scooters[] = $row; } } $stmt->close(); // WhatsApp number $whatsapp_number = "919345994249"; ?>
Experience the perfect blend of style, performance, and comfort with our exclusive range of TVS scooters
Premium Models
Color Options
Industry Awards
Happy Customers
We couldn't find any scooters matching your search criteria. Try adjusting your search.
Experience the thrill of TVS scooters firsthand. Book your test ride today!
Schedule Your Ride