<?
header('Access-Control-Allow-Origin: *');
//header('Content-Type: application/json');

$id = $_GET['id'];
/*
if ($id){
    echo $id;
}
else {
    echo 'All Items';
}
*/


$mysqli = new mysqli("localhost", "afxtech1_myori", "myori2017", "afxtech1_myori");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 


//$id = '003';
$query = "SELECT id, name, location, photo, remark1, remark2, officer, status, rpt_txn, area FROM reports WHERE id = '" .$id. "' LIMIT 1";
$dbresult = $mysqli->query($query);

//echo 'Hello...here1';
//die();

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'id' => $row['id'],
        'name' => $row['name'],
        'location' => $row['location'],
        'photo' => $row['photo'],
        'status' => $row['status'],
        'remark1' => $row['remark1'],
        'remark2' => $row['remark2'],
        'officer' => $row['officer'],
        'status' => $row['status'],
        'area' => $row['area'],
        'rpt_txn' => $row['rpt_txn']
    );
}

if($dbresult){
    $result = json_encode($data);              
}
else {
    $result = "{success:false}";
}

echo $result;

?>