<?php

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

$nfc = $_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 * FROM items WHERE nfc = '" .$nfc. "' " ;
$dbresult = $mysqli->query($query);

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

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'nfc' => $row['nfc'],
        'serialno' => $row['serialno'],
        'photo' => $row['photo'],
        'status' => $row['status'],
        'details' => $row['details'],
        'jenama' => $row['jenama'],
        'model' => $row['model'],
        'attrib3' => $row['attrib3'],
        'attrib4' => $row['attrib4'],
        'attrib5' => $row['attrib5'],
        'attrib6' => $row['attrib6'],
        'attrib7' => $row['attrib7'],
        'produk' => $row['produk'],
        'sku' => $row['sku'],
        'type' => $row['type'],
        'waranti' => $row['waranti'],
        'insuran' => $row['insuran'],
        'prod_year' => $row['prod_year'],
        'manu' => $row['manu']
    );
}

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

echo $result;


?>