<?php
include("../sql.php");
$connectionInfo = array("Database" => "$dbname", "UID" => "$username", "PWD" => "$password", "CharacterSet" => "UTF-8");
$conn = sqlsrv_connect($hostname, $connectionInfo);
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}
$data = array();
$category = array();
$project = array();
$sql = "SELECT [category_id],[category_name] FROM [21000X].[dbo].[Construction_Category]";
$fetchResult = sqlsrv_query($conn, $sql);
while ($row = sqlsrv_fetch_array($fetchResult,1)) {
    array_push($category,$row);
}
$sql = "SELECT [project_id],[project_name],[category_id] FROM [21000X].[dbo].[Project_Table]";
$fetchResult = sqlsrv_query($conn, $sql);
while ($row = sqlsrv_fetch_array($fetchResult,1)) {
    array_push($project,$row);
}
$data["category"] = $category;
$data["project"] = $project;
echo json_encode($data,JSON_UNESCAPED_UNICODE);
