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

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

if (isset($_REQUEST['itemcode'])){
    $itemcode = $_REQUEST['itemcode'];
    $prodtype = $_REQUEST['prodtype'];
    if(!empty($prodtype)){
        $prodcond = " and `prodtype`='$prodtype'";
    }
//    $series = $_REQUEST['series'];
    
        $getitm  = mysqli_query($conn, "SELECT `code`, `name` FROM `item` WHERE `code`='$itemcode' $prodcond ORDER BY `name`")or die(mysqli_error($conn));
        $itm     = mysqli_fetch_array($getitm);

        Echo "<option value='$itm[code]'>$itm[name]</option>";
        $getitm2 = mysqli_query($conn, "SELECT code, name FROM `item` where code != '' $prodcond ORDER BY `name`")or die(mysqli_error($conn));
        while ($itm2 = mysqli_fetch_array($getitm2)) {
              Echo "<option value='$itm2[code]'>$itm2[name]</option>";
        }
}
?>