<?php
header('Content-Type: application/json');
require 'db_connect.php';

// Buscamos a los 5 usuarios con más créditos donados
$sql = "SELECT google_id, name, picture_url, custom_pic, total_donated FROM users WHERE total_donated > 0 ORDER BY total_donated DESC LIMIT 5";
$result = $conn->query($sql);
$donors = [];

if ($result) {
    while($row = $result->fetch_assoc()) {
        $donors[] = $row;
    }
}

echo json_encode($donors);
$conn->close();
?>
