<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

include 'includes/db.php';

echo "<h2>Database Repair Status</h2>";

$sql = "CREATE TABLE IF NOT EXISTS blogs (
    id INT(11) NOT NULL AUTO_INCREMENT,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL,
    image_url VARCHAR(255) DEFAULT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id)
)";

if ($conn->query($sql) === TRUE) {
    echo "<div style='color: green; padding: 20px; border: 1px solid green;'>
        <h3>✅ Success!</h3>
        <p>The 'blogs' table has been successfully created.</p>
        <p>You can now go back to <a href='admin/manage_blogs.php'>Manage Blogs</a>.</p>
    </div>";
} else {
    echo "<div style='color: red; padding: 20px; border: 1px solid red;'>
        <h3>❌ Error</h3>
        <p>Failed to create table: " . $conn->error . "</p>
    </div>";
}

$conn->close();
?>
