<?php
include "../config.php";
$data = array();
if (!empty($_POST["id"])) {
    $id = $_POST['id'];
	$time = $_POST['timeX'];
	$timeZ = "('".implode("','",$time)."')";
	$columnS=array("Q9g","Region","Zone");
    $mq=query_marge($time,$columnS);
    
     $id= explode(",",$id);
	//echo "<br><Br>";
	$zone_arr = '('.'"' . implode('", "', $id) . '"'.')';	
     $query = "SELECT DISTINCT `Region` FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND `Zone` IN $zone_arr";
    $result = mysqli_query($conn,$query);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            array_push($data,$row['Region']);
            //echo '<option value="' . $row['zone'] . '">' . $row['zone'] . '</option>';
        }
    }
}
//echo "<br><Br>";
echo json_encode($data);

?>