<?php
require_once('includes/load.php');
$term = $_POST['term'];

// Perform a database query to search for products
$query = "SELECT part_number, name FROM products WHERE part_number LIKE '%$term%' OR name LIKE '%$term%'";
$result = $db->query($query);

// Fetch and format the results
$data = array();
while ($row = $db->fetch_assoc($result)) {
    $data[] = array(
        'label' => $row['part_number'] . ' - ' . $row['name'],
        'value' => $row['part_number'] // You can use any unique identifier for value
    );
}

// Return the results as JSON
echo json_encode($data);
?>
