<?php
include "../../root.class.php";
$db = new db_safeguard();

if (isset($_POST['stock_type'])) {

$type = $_POST['stock_type'];

$stock_res = $db->query("stock","SELECT * FROM stock WHERE stock_type_id = $type");

}


if (isset($_POST['type'])) {
    
    $type = $_POST['type'];

    $stock_res = $db->query("stock","SELECT * FROM stock WHERE stock_type_id = 2 AND item_name LIKE '%".$type."%'");

    if ($stock_res && $stock_res->num_rows > 0) {
        while ($row = $stock_res->fetch_assoc()) {
            $options .= "<option value='".$row['record_id']."'>".$row['item_name']."</option>";
        }
    }

    echo $options;

} else {
    exit;
}

if (isset($_POST['size'])) {

    
    if ($stock_res && $stock_res->num_rows > 0) {
        while ($row = $stock_res->fetch_assoc()) {
            $options .= "<option value='".$row['record_id']."'>".$row['item_name']."</option>";
        }
    }

    echo $options;
} else {
    exit;
}