Discover by Category

query("SELECT * FROM cuisines ORDER BY name"); $cuisines = $cuisine_stmt->fetchAll(PDO::FETCH_ASSOC); // Placeholder images - we'll make these dynamic later $cuisine_images = [ 'American' => 'assets/images/pexels/1639557.jpg', 'Asian' => 'assets/images/pexels/2347311.jpg', 'BBQ' => 'assets/images/pexels/161963.jpg', 'Breakfast' => 'assets/images/pexels/376464.jpg', 'Cafe' => 'assets/images/pexels/312418.jpg', 'Dessert' => 'assets/images/pexels/1099680.jpg', 'Fast Food' => 'assets/images/pexels/1633578.jpg', 'Healthy' => 'assets/images/pexels/1640777.jpg', 'Indian' => 'assets/images/pexels/958545.jpg', 'Italian' => 'assets/images/pexels/1260968.jpg', 'Mexican' => 'assets/images/pexels/461198.jpg', 'Pizza' => 'assets/images/pexels/1146760.jpg', 'Seafood' => 'assets/images/pexels/1639565.jpg', 'Vegetarian' => 'assets/images/pexels/1143754.jpg', ]; foreach ($cuisines as $cuisine): $image_url = $cuisine_images[$cuisine['name']] ?? 'https://picsum.photos/600?random=' . $cuisine['id']; ?> <?= htmlspecialchars($cuisine['name']) ?>

onchange="this.form.submit()">
Clear Filters
prepare("SELECT name FROM cuisines WHERE id = ?"); $cuisine_stmt->execute([$cuisine_id]); $cuisine_name = $cuisine_stmt->fetchColumn(); if ($cuisine_name) { $page_title = htmlspecialchars($cuisine_name) . " Restaurants"; } } ?>

= ? AND r.days_open LIKE ?"; $params[] = $current_time; $params[] = $current_time; $params[] = '%' . $current_day . '%'; } if (!empty($where_clauses)) { $sql .= " WHERE " . implode(' AND ', $where_clauses); } $sql .= " GROUP BY r.id, r.name, r.image_url, r.opening_time, r.closing_time, r.days_open"; // Add rating filter (HAVING clause) $selected_min_rating = isset($_GET['min_rating']) && is_numeric($_GET['min_rating']) ? (int)$_GET['min_rating'] : 0; if ($selected_min_rating > 0) { $sql .= " HAVING AVG(rt.rating) >= ?"; $params[] = $selected_min_rating; } $sql .= " ORDER BY r.name"; $stmt = db()->prepare($sql); $stmt->execute($params); $restaurants = $stmt->fetchAll(); if (empty($restaurants)) { echo '

No restaurants found matching your criteria.

'; } else { foreach ($restaurants as $restaurant) { // Get cuisines for this restaurant $cuisine_sql = "SELECT c.name FROM cuisines c JOIN restaurant_cuisines rc ON c.id = rc.cuisine_id WHERE rc.restaurant_id = ?"; $cuisine_stmt = db()->prepare($cuisine_sql); $cuisine_stmt->execute([$restaurant['id']]); $restaurant_cuisines_list = $cuisine_stmt->fetchAll(PDO::FETCH_COLUMN); echo ''; echo '' . htmlspecialchars($restaurant['name']) . ''; echo '
'; echo '

' . htmlspecialchars($restaurant['name']) . '

'; echo '

' . htmlspecialchars(implode(', ', $restaurant_cuisines_list)) . '

'; echo '
'; if ($restaurant['rating_count'] > 0) { echo '
'; echo ''; echo '' . htmlspecialchars(number_format($restaurant['average_rating'], 1)) . ''; echo '
'; } else { echo '
No ratings yet
'; } echo '
'; echo '
'; echo '
'; } } ?>