<?php
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 * FROM manufacturer WHERE id = '" .$id. "' ";
$dbresult = $mysqli->query($query);

$mysqli->close();

$data = [];

while($row = $dbresult->fetch_array(MYSQLI_ASSOC)){
    $data[] = array(
        'id' => $row['id'],
        'regno' => $row['regno'],
        'name' => $row['name'],
        'address' => $row['address'],
        'postcode' => $row['postcode'],
        'town' => $row['town'],
        'state' => $row['state'],
        'telephone' => $row['telephone'],
        'fax' => $row['fax'],
        'url' => $row['url'],
        'officer' => $row['officer'],
        'phone' => $row['phone'],
        'email' => $row['email'],
        'type' => $row['type'],
        'status' => $row['status']
    );
}

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

echo $result;

?>