<?php
require_once('includes/load.php');

if (isset($_GET['query'])) {
    $query = $_GET['query'];
    
    // Ambil data part number dan name dari tabel products
    $query = "SELECT part_number, name FROM products WHERE part_number LIKE '%$query%' OR name LIKE '%$query%'";
    $result = $db->query($query);
    $products = array();

    while ($row = $result->fetch_assoc()) {
        $products[] = array('part_number' => $row['part_number'], 'name' => $row['name']);
    }

    echo json_encode($products); // Mengubah data menjadi format JSON
}
?>
