<?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];

// $success = false;


if (isset($_REQUEST["party"])) {
    $party = $_REQUEST['party'];

    $query = "SELECT a.*, b.`name` as stname FROM `accmast` a LEFT JOIN `state` b ON a.`state`=b.`name` WHERE a.accode ='$party'";
    $result = mysqli_query($conn, $query) or die(mysqli_error($conn));
    $r = mysqli_fetch_assoc($result);

    $rows = array();
    $ctr = 0;
    $rows = array(
        'success' => true,
        'name' => "$r[name]",
        'add1' => "$r[add1]",
        'add2' => "$r[add2]",
        'add3' => "$r[add3]",
        'city' => "$r[city]",
        'pin' => "$r[pin]",
        'gstno' => "$r[gstno]",
        'state' => "$r[stname]",
        'statecode' => "$r[statecode]"
    );

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

?>