<?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];
$zroot = $_SESSION["zdbroot"];

// $fseries = $_SESSION["series_" . $dbname];
// $keycond = "and `series`='$fseries'";

$success = false;


if (isset($_REQUEST["prodcode"])) {
    
    $prodcode = $_REQUEST['prodcode'];
    
    $getp = mysqli_query($conn, "SELECT name,unit,rate FROM `product` WHERE prodcode = '$prodcode'")or die(mysqli_error($conn));
    $r2 = mysqli_fetch_assoc($getp);
    

    $rows = array();
    $ctr = 0;
    $rows = array('success' => true,
        'prodname'   => "$r2[name]",
        'rate'   => "$r2[rate]",
        'unit'   => "$r2[unit]");

    header("Content-type: application\json");
    echo json_encode($rows);
}

