<?php
session_start();

require_once __DIR__ . '/config/db.php';


// Check if tables exist
$tables = ['orders', 'order_items', 'coupons', 'order_tracking', 'cart'];

echo "<h2>✅ Database Check</h2>";
echo "<p><strong>Database:</strong> " . $db . "</p>";
echo "<h3>Tables Status:</h3>";
echo "<ul>";

foreach ($tables as $table) {
    $result = $conn->query("SHOW TABLES LIKE '$table'");
    if ($result->num_rows > 0) {
        echo "<li style='color: green;'>✅ $table - EXISTS</li>";
    } else {
        echo "<li style='color: red;'>❌ $table - MISSING</li>";
    }
}

echo "</ul>";

echo "<h3>Cart Items:</h3>";
$cart_query = $conn->query("SELECT COUNT(*) as count FROM cart");
$row = $cart_query->fetch_assoc();
echo "<p>Cart items in database: " . $row['count'] . "</p>";

echo "<br><br>";
echo "<h3>🔧 Actions:</h3>";
echo "<p><a href='auth-system/migrate-checkout.php' style='padding: 10px 20px; background: #d4a574; color: white; text-decoration: none; border-radius: 5px;'>Run Database Migration</a></p>";
?>
