<?php
include '../config.php';
$data = array();
$sql_base;

$time = $_POST['timeX'];

$timeZ = "('".implode("','",$time)."')";

      /*host script start*/
      $columnS=array("record","Q9g","Q16_n3");
      $mq=query_marge($time,$columnS);
      $host=mysqli_query($conn,"SELECT avg(`Q16_n3`) FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND  1=1");
         
      $hostV=mysqli_fetch_array($host); 
      $data['host'] = round($hostV[0]);
      /*host script end*/

      /*empathy script start*/
      $columnS=array("record","Q9g","Q19c1_n3");
      $mq=query_marge($time,$columnS);
      $empathy=mysqli_query($conn,"SELECT avg(`Q19c1_n3`) FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND  1=1");
      $empathyV=mysqli_fetch_array($empathy); 
      $data['empathy'] = round($empathyV[0]);
      /*empathy script end*/

      /*anticipate script start*/
      $columnS=array("record","Q9g","Q19e1_n3");
      $mq=query_marge($time,$columnS);
      $anticipate=mysqli_query($conn,"SELECT avg(`Q19e1_n3`) FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND  1=1");
      $anticipateV=mysqli_fetch_array($anticipate); 
      $data['anticipate'] = round($anticipateV[0]);
      /*anticipate script end*/

      /*respect script start*/
      $columnS=array("record","Q9g","Q35_n3");
      $mq=query_marge($time,$columnS);
      $respect=mysqli_query($conn,"SELECT avg(`Q35_n3`) FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND  1=1");
      $respectV=mysqli_fetch_array($respect); 
      $data['respect'] = round($respectV[0]);
      /*respect script end*/

      /*thanks script start*/
       $columnS=array("record","Q9g","Q36_n3");
      $mq=query_marge($time,$columnS);
      $thanks=mysqli_query($conn,"SELECT avg(`Q36_n3`) FROM ($mq) AS t WHERE t.`Q9g` IN $timeZ AND  1=1");
      $thanksV=mysqli_fetch_array($thanks); 
      $data['thanks'] = round($thanksV[0]);
      /*thanks script end*/
   
    

    

    echo json_encode($data);


?>