<?php
include '../koneksi.php';

$keyword = $_POST['barang'];

$query = mysqli_query($konek, "
    SELECT *
    FROM barang
    WHERE nama_barang LIKE '%$keyword%'
    LIMIT 5
");

if (mysqli_num_rows($query) > 0) {
    while ($row = mysqli_fetch_assoc($query)) {
        echo '<div class="list-group-item barang-item"
                data-id="' . $row['idbarang'] . '" 
                data-nama="' . $row['nama_barang'] . '">
                ' . $row['nama_barang'] .
            '</div>';
    }
}
