<?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['brand'])) {
    $mbrand = $_REQUEST['brand'];
    $getbr = mysqli_query($conn, "SELECT code,name FROM `brand` WHERE `name`='$mbrand' order by `name`") or die(mysqli_error($conn));
    $bcode = mysqli_fetch_array($getbr);

    $gitemcode = mysqli_query($conn, "SELECT * FROM `item` WHERE `brand`='$bcode[code]' order by `name`") or die(mysqli_error($conn));
    
    

//    echo "<datalist id='itemcode' char='#'>";
//    echo"<option>";

//    $gitemcode = mysqli_query($conn, 'SELECT * FROM `item`')or die(mysqli_error($conn));
    while ($fitemcode = mysqli_fetch_array($gitemcode)) {
        Echo "<option value='$fitemcode[code]'></option>";
    }
//    echo "</datalist>";
    
   
    
}