<?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($_POST['code'])) {
    $itemgrp = $_POST['code'];
    $grpcond = "";
    if ($rawgrp != '') {
        $grpcond = "and `itemgrp`='$itemgrp'";
    }
    $getsub = mysqli_query($conn, "SELECT * FROM `item` where code !='' $grpcond")or die(mysqli_error($conn));
    echo "<option></option>";
    while ($msub = mysqli_fetch_array($getsub)) {
        $getsupp = mysqli_query($conn, "SELECT accode,name FROM `accmast` where accode ='$msub[supplier]'")or die(mysqli_error($conn));
        $fetsupp = mysqli_fetch_array($getsupp);
        echo "<option value='$fetsupp[accode]'>$fetsupp[name]</option> ";
    }
}
?>