<?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['product'])) {
    $product = $_REQUEST['product'];
    $productcond = '';

    if (!empty($_REQUEST['product'])) {
        $productcond = "AND name = '$product' ";
    }

    $getprodcode = mysqli_query($conn, "SELECT prodcode,name FROM `product` WHERE `code` != '' $productcond ")or die(mysqli_error($conn));
    $m2 = mysqli_fetch_array($getprodcode);

    $prodcode = $m2['prodcode'];
    $rows2 = array('prodcode' => "$prodcode");
    header("Content-type: application\json");
    echo json_encode($rows2);
}



