<?php

$r = array();
require_once __DIR__ . '/db_config.php';


if (isset($_POST["cname"])) {
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());
$cname = $_POST['cname'];

$query="SELECT subfacility_name,subfacility_id FROM subfacility WHERE delete_status=0 AND companyname='$cname'";

$result = mysqli_query($con,$query);
if(!empty($result) && mysqli_num_rows($result) > 0){
    while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
        array_push($r, $row);
    }
}
mysqli_close($con);               
echo json_encode($r);
}
?>