<?php
include_once '../db/koneksi.php';
$user = isset($_GET['user']) ? $_GET['user'] : '';

// Mengambil data berdasarkan created_at karena tidak ada kolom 'tanggal'
$data = mysqli_query($koneksi, "SELECT created_at, jumlah, status FROM tb_deposit WHERE username = '$user' AND status = 'Sukses' ORDER BY created_at DESC");
?>

<div class="mb-3">
<strong>ID Pengguna:</strong> <?php echo htmlspecialchars($user); ?>
</div> 
   <table class="table table-bordered">
    <thead>
        <tr>
            <th>No</th>
            <th>Tanggal Deposit</th>
            <th>Jumlah</th>
            <th>Status</th>
        </tr>
    </thead>
    <tbody>
        <?php 
        $no = 1;
        while($r = mysqli_fetch_array($data)) { ?>
        <tr>
            <td><?php echo $no++; ?></td>
            <td><?php echo date("d-m-Y H:i", strtotime($r['created_at'])); ?></td>
            <td>Rp <?php echo number_format($r['jumlah'], 0, ',', '.'); ?></td>
            <td><?php echo $r['status']; ?></td>
        </tr>
        <?php } ?>
    </tbody>
</table>