<?php

require_once('Conn.php');
header('Content-Type: application/json');

if($_SERVER['REQUEST_METHOD'] != 'GET') {
    header('HTTPS/1.1 405');
    echo json_encode(array(["message" => "method not allowed" , "status" => "false"]));
    exit;
}


$query = "SELECT bid , bNo , bName , landmark , isDeleted FROM building_list ";

$result = mysqli_query($connection , $query);
if($result) {
    $response = array();
    $i = 0;
    while($row = mysqli_fetch_assoc($result))  {
        $response[$i]['bid'] = $row['bid'];
        $response[$i]['bNo'] = $row['bNo'];
        $response[$i]['nomenclature'] = $row['bName'];
        $response[$i]['landmark'] = $row['landmark'];
        $response[$i]['isDeleted'] = $row['isDeleted'];
        $i++;        

    }

    echo json_encode($response);
}
else {
    echo json_encode(array(["message" => mysqli_error($connection) , "status" => "false"])); 
}


?>