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

if (isset($_GET['part_number'])) {
    $partNumber = $db->escape($_GET['part_number']);

    $query = "SELECT part_number, name FROM products WHERE part_number = '$partNumber'";
    $result = $db->query($query);

    if ($result) {
        $productData = $result->fetch_assoc();
        echo json_encode($productData);
    } else {
        echo json_encode(array("error" => "Failed to fetch data."));
    }
} else {
    echo json_encode(array("error" => "Invalid request."));
}
?>
