<?php

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $block_id=$request->getParsedBody()['block_id'];
		$room_name=$request->getParsedBody()['room_name'];            
			    	
                          $floors=$request->getParsedBody()['floors'];
$response=array();


$sqll="(SELECT * FROM set_rooms WHERE  room_name='$room_name' )";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{
$sql="INSERT INTO set_rooms(block_id,room_name,floors) VALUES ('$block_id','$room_name','$floors')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"block_id"=>$block_id,
	"room_name"=>$room_name,

	"floors"=>$floors,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data inserted successfully",'set_rooms' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
}

?>