<?php
include 'includes/db.php';

// Create Analytics Table
$sql = "CREATE TABLE IF NOT EXISTS site_analytics (
    id INT PRIMARY KEY,
    total_visits INT DEFAULT 0
)";

if ($conn->query($sql) === TRUE) {
    echo "Table 'site_analytics' created successfully.<br>";
} else {
    echo "Error creating table: " . $conn->error . "<br>";
}

// Insert initial row if not exists
$sql_insert = "INSERT INTO site_analytics (id, total_visits) VALUES (1, 0) ON DUPLICATE KEY UPDATE id=1";
if ($conn->query($sql_insert) === TRUE) {
    echo "Analytics initialized successfully.<br>";
} else {
    echo "Error initializing analytics: " . $conn->error . "<br>";
}

echo "Setup complete. You can delete this file now.";
?>
