<?
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");
include_once("db_connect.php");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 


//$id = '003';
$query = "SELECT id, photo, photo2, photo3, photo4 
            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'],
        'photo' => $row['photo'],
        'photo2' => $row['photo2'],
        'photo3' => $row['photo3'],
        'photo4' => $row['photo4']
    );
}

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

echo $result;

?>