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

if (!$_SESSION["manu"]) {
    http_response_code(401);
    die();
}

$manu = $_SESSION["manu"];

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


include_once("db_connect.php");
if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} 


$query = "SELECT * FROM cocs WHERE nfc = '" .$nfc. "' AND manu = '" .$manu. "' ";
$dbresult = $mysqli->query($query);

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

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'remark' => $row['remark'],
        'filename' => '/m/ws/cocs/'.$row['filename']
    );
}

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

echo $result;

?>