<?php
require_once 'includes/config.php';
require_once 'includes/db.php';

// Check the structure of the product_comments table
try {
    echo "<h1>Product Comments Table Structure</h1>";
    
    // Get table structure
    $stmt = $pdo->query("DESCRIBE product_comments");
    $columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo "<table border='1'>";
    echo "<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default</th><th>Extra</th></tr>";
    
    foreach ($columns as $column) {
        echo "<tr>";
        echo "<td>" . $column['Field'] . "</td>";
        echo "<td>" . $column['Type'] . "</td>";
        echo "<td>" . $column['Null'] . "</td>";
        echo "<td>" . $column['Key'] . "</td>";
        echo "<td>" . $column['Default'] . "</td>";
        echo "<td>" . $column['Extra'] . "</td>";
        echo "</tr>";
    }
    
    echo "</table>";
    
    // Check if there are any comments in the table
    echo "<h2>Sample Comments</h2>";
    $stmt = $pdo->query("SELECT * FROM product_comments LIMIT 5");
    $comments = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    if ($comments) {
        echo "<pre>" . print_r($comments, true) . "</pre>";
    } else {
        echo "<p>No comments found in the table.</p>";
    }
} catch (Exception $e) {
    echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
?>