<?php
require_once __DIR__ . '/includes/auth.php';
$conn = getDBConnection();
$items = [];
$result = $conn->query("SELECT name, relationship, testimonial, rating FROM testimonials WHERE approved = 1 ORDER BY created_at DESC");
while ($row = $result->fetch_assoc()) { $items[] = $row; }
$conn->close();
if (!$items) {
    $items = [
        ['name' => 'Mary Thompson', 'relationship' => 'Daughter of Resident', 'testimonial' => 'The staff treats my mother like family. We finally feel at peace knowing she is in caring hands.', 'rating' => 5],
        ['name' => 'Robert Hayes', 'relationship' => 'Resident', 'testimonial' => 'I enjoy the activities, the meals, and the friendly atmosphere here every day.', 'rating' => 5]
    ];
}
?>
<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>Testimonials - Oldage Home</title><link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'><link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css'><link href='https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap' rel='stylesheet'><link rel='stylesheet' href='css/style.css'></head><body><?php include 'includes/header.php'; ?><section class='hero-section' style='background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%); min-height: 40vh;'><div class='container'><div class='row'><div class='col text-center'><h1 class='display-4 fw-bold text-white mb-4'>What Families Say</h1><p class='lead text-white'>Real feedback from residents and their loved ones</p></div></div></div></section><section class='py-5'><div class='container'><div class='row justify-content-center'><div class='col-lg-10'><?php foreach ($items as $item): ?><div class='testimonial-card mb-4'><div class='mb-3 text-warning fs-5'><?php echo str_repeat('?', (int) $item['rating']); ?></div><p class='testimonial-text'><?php echo htmlspecialchars($item['testimonial']); ?></p><div class='testimonial-author'><div><h6><?php echo htmlspecialchars($item['name']); ?></h6><small><?php echo htmlspecialchars($item['relationship']); ?></small></div></div></div><?php endforeach; ?></div></div></div></section><?php include 'includes/footer.php'; ?><script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js'></script><script src='js/main.js'></script></body></html>

