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.motorcycle_name LIKE ? OR m.motorcycle_headline LIKE ? OR m.motorcycle_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-125': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) < 125"; break; case '125-200': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) BETWEEN 125 AND 200"; break; case '200-300': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) BETWEEN 200 AND 300"; break; case 'above-300': $where_conditions[] = "CAST(REGEXP_SUBSTR(m.displacement, '^[0-9]+') AS UNSIGNED) > 300"; break; } } if (!empty($price_filter)) { switch($price_filter) { case 'under-1lac': $where_conditions[] = "(SELECT MIN(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) < 100000"; break; case '1-2lac': $where_conditions[] = "(SELECT MIN(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) BETWEEN 100000 AND 200000"; break; case '2-3lac': $where_conditions[] = "(SELECT MIN(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) BETWEEN 200000 AND 300000"; break; case 'above-3lac': $where_conditions[] = "(SELECT MIN(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) > 300000"; break; } } // Count total $count_query = "SELECT COUNT(DISTINCT m.motorcycle_id) as total FROM motorcycles 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 motorcycles for current page $query = "SELECT m.*, (SELECT MIN(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) as min_price, (SELECT MAX(price) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) as max_price, (SELECT COUNT(*) FROM motorcycle_colors WHERE motorcycle_id = m.motorcycle_id) as color_count, (SELECT mc.color_code FROM motorcycle_colors mc WHERE mc.motorcycle_id = m.motorcycle_id LIMIT 1) as first_color, (SELECT mi.image_path FROM motorcycle_colors mc LEFT JOIN motorcycle_images mi ON mc.color_id = mi.color_id AND mi.is_primary = 1 WHERE mc.motorcycle_id = m.motorcycle_id LIMIT 1) as primary_image FROM motorcycles m WHERE " . implode(" AND ", $where_conditions) . " ORDER BY m.motorcycle_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(); $motorcycles = []; if ($result && $result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // Get all colors for this motorcycle $color_sql = "SELECT color_name, color_code, price FROM motorcycle_colors WHERE motorcycle_id = ? ORDER BY price"; $color_stmt = $conn->prepare($color_sql); $color_stmt->bind_param("i", $row['motorcycle_id']); $color_stmt->execute(); $color_result = $color_stmt->get_result(); $row['colors'] = []; while ($color = $color_result->fetch_assoc()) { $row['colors'][] = $color; } $color_stmt->close(); $motorcycles[] = $row; } } $stmt->close(); // Get filter options $cc_ranges = [ 'under-125' => 'Under 125cc', '125-200' => '125cc - 200cc', '200-300' => '200cc - 300cc', 'above-300' => 'Above 300cc' ]; $price_ranges = [ 'under-1lac' => 'Under ₹1 Lakh', '1-2lac' => '₹1 Lakh - ₹2 Lakhs', '2-3lac' => '₹2 Lakhs - ₹3 Lakhs', 'above-3lac' => 'Above ₹3 Lakhs' ]; // WhatsApp number $whatsapp_number = "+919345994249"; ?> TVS Motorcycles - Performance Machines | Vijai Motors
Opening WhatsApp...
RACING HERITAGE

Unleash the Beast

Discover our range of high-performance motorcycles engineered for thrill-seekers and racing enthusiasts.

15+
Models
200+
Racing Wins
50k+
Riders

Motorcycle Models

query("SELECT AVG(CAST(REGEXP_SUBSTR(max_power, '^[0-9.]+') AS DECIMAL(10,2))) as avg_power FROM motorcycles WHERE max_power IS NOT NULL AND max_power != ''")->fetch_assoc()['avg_power']; ?>

+ PS

Avg. Power

200+

Racing Wins

50k+

Happy Riders

Clear Filters
Our Collection

Performance Motorcycles

$motorcycle): ?>
Bestseller
Performance
prepare($img_sql); $img_stmt->bind_param("i", $motorcycle['motorcycle_id']); $img_stmt->execute(); $img_result = $img_stmt->get_result(); if ($img_result && $img_result->num_rows > 0) { $img = $img_result->fetch_assoc(); $image_path = "uploads/motorcycles/colors/" . $img['image_path']; if (file_exists($image_path)) { $display_image = $image_path; } } $img_stmt->close(); } ?> <?php echo htmlspecialchars($motorcycle['motorcycle_name']); ?>
Color Options

Engine
Power
Weight
Fuel
Available Colors:
5): ?>
+ more colors
Starting from
- ₹
1): ?>

No Motorcycles Found

We couldn't find any motorcycles matching your search criteria. Try adjusting your filters.

Ready to Ride?

Experience the thrill of our performance motorcycles. Book your test ride today!

Schedule Test Ride
close(); ?>