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

// Check column existence
$col = $conn->query("SHOW COLUMNS FROM found_items LIKE 'surrenderer_gender'");
echo $col->num_rows > 0 ? "✅ Column EXISTS<br>" : "❌ Column MISSING — adding now...<br>";

if ($col->num_rows === 0) {
    $r = $conn->query("ALTER TABLE found_items ADD COLUMN surrenderer_gender ENUM('male','female') DEFAULT NULL");
    echo $r ? "✅ Column added successfully.<br>" : "❌ Error: " . $conn->error . "<br>";
}

// Show last 5 found_items
$rows = $conn->query("SELECT id, item_name, surrendered_by, surrenderer_gender FROM found_items ORDER BY id DESC LIMIT 5");
echo "<br><b>Last 5 found items:</b><br>";
while ($r = $rows->fetch_assoc()) {
    echo "ID:{$r['id']} | {$r['item_name']} | surrendered_by: {$r['surrendered_by']} | gender: {$r['surrenderer_gender']}<br>";
}
