<?php

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


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

if (isset($_REQUEST['name'])) {
    $code = mysqli_real_escape_string($conn, $_REQUEST["name"]);
    $brand = mysqli_real_escape_string($conn, $_REQUEST["brand"]);
    $getbr = mysqli_query($conn, "SELECT code,name FROM `brand` WHERE `name`='$brand'") or die(mysqli_error($conn));
    $bcode = mysqli_fetch_array($getbr);
//   BROWSE($code);
    $result = mysqli_query($conn, "SELECT `cost`, `selling`,`hsncode`,`gstperc`,name,code FROM  `item` WHERE `code`='$code' and brand = '$bcode[code]'") or die(mysqli_error($conn));
    $array = mysqli_fetch_object($result);
    header("Content-type: application/json");
    echo json_encode($array);
}
?>
