<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$admin = $_SESSION["admin_" . $dbname];

if (isset($_REQUEST['itemcode'])) {
    $mitemcode = $_REQUEST['itemcode'];
    $mbrand = $_REQUEST['brand'];
    // $getbr = mysqli_query($conn, "SELECT code,name FROM `item` WHERE `itemcode`='$mitemcode'") or die(mysqli_error($conn));
//    echo $bcode[code];

    $getitem = mysqli_query($conn, "SELECT barcode,code,name FROM `item` WHERE `code`='$mitemcode' and brand = '$mbrand'") or die(mysqli_error($conn));
    $bcode = mysqli_fetch_array($getitem);


    Echo "<option value='$bcode[barcode]'>$bcode[name]</option>";
    $getitem2 = mysqli_query($conn, "SELECT barcode,code,name FROM `item` WHERE brand = '$mbrand'") or die(mysqli_error($conn));
    while ($fitcd = mysqli_fetch_array($getitem2)) {
        Echo "<option value='$fitcd[barcode]'>$fitcd[name]</option>";
    }
}