<?php
header('Content-Type: application/json');

// DB connection (same pattern as save_wish.php)
require_once '/home12/fiberule/public_html/kartikthanaweddingdinner/config/db.php';

try {
    $stmt = $pdo->query("
        SELECT name, message 
        FROM wishes 
        ORDER BY created_at DESC 
        LIMIT 20
    ");

    $wishes = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode($wishes);

} catch (Exception $e) {
    echo json_encode([]);
}