<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../config/database.php';

$sql = "SELECT id AS __backendId, username, pin_code, role, created_at FROM users ORDER BY id DESC";
$result = $mysqli->query($sql);
$data = [];
if ($result) {
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
}

echo json_encode($data);
?>