<?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'])){
//    browse($_REQUEST['name']);
    $itemname = mysqli_real_escape_string($conn, $_REQUEST["name"]);
    $result   = mysqli_query($conn, "SELECT * FROM `item` WHERE `name` = '$itemname' ") or die(mysqli_error($conn));
    if(mysqli_num_rows($result) > 0){
        $array   = mysqli_fetch_array($result);
        $rate    = $array["rate"];
        $barcode = $array["barcode"];
        $mcode   ="1";
    }else{
        $mcode   = 0;
        $rate    = 0;
        $barcode    = 0;
    }
    header("Content-type: application/json");
    $data=array("code"=>$mcode,"rate"=>$rate,"barcode"=>$barcode);
    echo json_encode($data);
}
?>