<?php
// =====================================================
// GET /user_info.php
// Response: JSON Array of all users (for autocomplete)
// =====================================================
require_once 'config.php';

$conn = getConnection();

$result = $conn->query("SELECT id, recharge_id, user_id, username, name, address, phone FROM users ORDER BY name ASC");

$users = [];
while ($row = $result->fetch_assoc()) {
    $users[] = [
        "id"          => (string)$row['id'],
        "recharge_id" => $row['recharge_id'],
        "user_id"     => $row['user_id'],
        "username"    => $row['username'],
        "name"        => $row['name'],
        "address"     => $row['address'],
        "phone"       => $row['phone']
    ];
}

echo json_encode($users);

$conn->close();
