<?php
include 'db.php';
$item_id = (int)$_GET['item_id'];

$q = $conn->query("
    SELECT bc.component_item_id, bc.quantity
    FROM bom_master bm
    JOIN bom_components bc ON bm.id = bc.bom_id
    WHERE bm.item_id = $item_id
");

$data = [];
while ($row = $q->fetch_assoc()) {
    $data[] = $row;
}
echo json_encode($data);
