<?php
require_once __DIR__ . '/../../../../function/connect.php';
session_start();
header('Content-Type: application/json');

if (!isset($_SESSION['extplayer'])) {
    echo json_encode([]);
    exit;
}

$extplayer = $_SESSION['extplayer'];

$q = mysqli_prepare($koneksi, "
    SELECT nominal, tanggal, status
    FROM tb_bonus
    WHERE id_user = ?
    AND id_bonus = '7'
    ORDER BY tanggal DESC
    LIMIT 20
");

mysqli_stmt_bind_param($q, 's', $extplayer);
mysqli_stmt_execute($q);
$result = mysqli_stmt_get_result($q);

$data = [];
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = $row;
}

echo json_encode($data);