<?php
require_once __DIR__ . '/db_config.php';

// Check if pages table exists
$check_table = $conn->query("SHOW TABLES LIKE 'pages'");
echo "Table exists: " . ($check_table->num_rows > 0 ? "YES" : "NO") . "<br><br>";

// Get all pages from database
$result = $conn->query("SELECT * FROM pages ORDER BY menu_order ASC");
echo "Total pages in database: " . $result->num_rows . "<br><br>";

if ($result->num_rows > 0) {
    echo "<table border='1' cellpadding='10' style='margin-top: 20px;'>";
    echo "<tr><th>ID</th><th>Title</th><th>Slug</th><th>URL</th><th>Featured</th><th>Order</th></tr>";
    
    while ($row = $result->fetch_assoc()) {
        echo "<tr>";
        echo "<td>" . $row['id'] . "</td>";
        echo "<td>" . $row['title'] . "</td>";
        echo "<td>" . $row['slug'] . "</td>";
        echo "<td>" . $row['url'] . "</td>";
        echo "<td>" . ($row['is_featured'] ? "YES" : "NO") . "</td>";
        echo "<td>" . $row['menu_order'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "<p style='color: red; font-size: 18px;'><strong>NO PAGES FOUND IN DATABASE!</strong></p>";
}

$conn->close();
?>
