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

echo json_encode($data);

?>