<?php
$response = new stdClass();
$total = array();

if (isset($_POST["AA_ACNO"]) && !empty($_POST["AA_ACNO"])) {
    $AA_ACNO = $_POST["AA_ACNO"];

    $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']);
    if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);

    $sql = "SELECT * FROM `" . $GLOBALS['arif_ac'] . "` WHERE `AA_ACNO` = '" . $conn->real_escape_string($AA_ACNO) . "'";
    $result = $conn->query($sql);

    if ($result && $result->num_rows > 0) {
        $rows = array();
        while ($row = $result->fetch_assoc()) {
            $rows[] = $row;
        }
        $total['status'] = 'Success';
        $total['data'] = $rows;
    } else {
        $total['status'] = 'Error';
        $total['statusmsg'] = 'No record found for ACNO: ' . $AA_ACNO;
    }

    $conn->close();
} else {
    $total['status'] = 'Error';
    $total['statusmsg'] = 'AA_ACNO missing in request!';
}

$response = $total;
echo json_encode($response);
?>
