<?php
include 'koneksi.php';
session_start();

// Mengambil data dari tabel keranjang_po (sesuaikan nama tabel Anda)
$query = mysqli_query($conn, "SELECT * FROM keranjang_po WHERE user_id = '".$_SESSION['user_id']."'");
?>

<div class="card card-secondary">
    <div class="card-header"><h3 class="card-title">Keranjang Barang</h3></div>
    <div class="card-body">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>No</th>
                    <th>Nama Barang</th>
                    <th>Jumlah</th>
                    <th>Aksi</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                $no = 1;
                if(mysqli_num_rows($query) > 0) {
                    while($row = mysqli_fetch_array($query)) {
                        echo "<tr>
                            <td>".$no++."</td>
                            <td>".$row['nama_barang']."</td>
                            <td>".$row['jumlah']."</td>
                            <td><button class='btn btn-danger btn-sm'>Hapus</button></td>
                        </tr>";
                    }
                } else {
                    echo "<tr><td colspan='4' class='text-center'>Keranjang kosong</td></tr>";
                }
                ?>
            </tbody>
        </table>
    </div>
</div>