<?php
header('Content-Type: application/json');
require 'db_connect.php';  // put your PDO connection code here or include it

try {
    $stmt = $pdo->query("SELECT id, title, slug, created_at, updated_at FROM pages ORDER BY created_at DESC");
    $pages = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode(['success' => true, 'pages' => $pages]);
} catch (Exception $e) {
    echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
