<?php

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$block_id = $request->getAttribute('block_id');
$floors = $request->getAttribute('floors');
$response=array();

if(isset($block_id)&&isset($floors)){
	$sql="SELECT set_rooms.room_id, set_rooms.block_id, set_rooms.room_name, set_rooms.floors, set_blocks.block_shortcode, set_blocks.floors FROM (set_rooms INNER JOIN set_blocks ON set_blocks.block_id = set_rooms.block_id) WHERE set_rooms.block_id=$block_id AND set_rooms.floors=$floors";
}

elseif(isset($block_id)){
	$sql="SELECT set_rooms.room_id, set_rooms.block_id, set_rooms.room_name, set_rooms.floors, set_blocks.block_shortcode, set_blocks.floors FROM (set_rooms INNER JOIN set_blocks ON set_blocks.block_id = set_rooms.block_id) WHERE set_rooms.block_id=$block_id";
}
else{
	$sql="SELECT set_rooms.room_id, set_rooms.block_id, set_rooms.room_name, set_rooms.floors, set_blocks.block_shortcode, set_blocks.floors FROM (set_rooms INNER JOIN set_blocks ON set_blocks.block_id = set_rooms.block_id)";
}
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $user=$row;
	}

echo json_encode($user);

?>