<?php
/**
 * List All Tables in Database
 * This script lists all tables to help identify the correct table name
 */

require_once 'config.php';

echo "=== All Tables in Database ===\n\n";

$result = $conn->query("SHOW TABLES");
if ($result) {
    $tables = [];
    while ($row = $result->fetch_array()) {
        $tables[] = $row[0];
    }
    
    echo "Found " . count($tables) . " tables:\n\n";
    
    foreach ($tables as $index => $table) {
        echo ($index + 1) . ". " . $table . "\n";
        
        // Check if table has a 'status' column
        $checkStatus = $conn->query("SHOW COLUMNS FROM `$table` LIKE 'status'");
        if ($checkStatus->num_rows > 0) {
            echo "   → Has 'status' column\n";
        }
        
        // Check if table name contains 'complaint'
        if (stripos($table, 'complaint') !== false) {
            echo "   → ⚠ Contains 'complaint' in name\n";
        }
    }
} else {
    echo "Error: " . $conn->error . "\n";
}

echo "\n=== Done! ===\n";
?>

