<?php
    include '_connect.php';
    // $lineid = $_REQUEST["lineid"];

    $lineid = 'Ue7755e5ad9b0b66baf75a8b756f2850f';
    // Ub5039f73e9edf5cbe5a8fac2c520e18e
    $sqlx = "SELECT ct_no,ps_name,ct_mobileno FROM EHONGDB.dbo.PERSON a
    left outer join (SELECT * FROM EHONGDB.dbo.hps_ctmain) b on (a.PS_PHONE=b.ct_mobileno)
    WHERE a.lineid IN ('$lineid')
    ORDER BY b.CT_DATE";
    $selectx=$dbh->prepare($sqlx);
    $selectx->execute();
    $sql_array = array();
    while ($fetchx=$selectx->fetch()) {
      // $sql_array[] = $fetchx;
      $ct_no = $fetchx['ct_no'];
      $ps_name = $fetchx['ps_name'];
      $ct_mobileno = $fetchx['ct_mobileno'];

      $sql_array[] = array(
      "ct_no" => $ct_no,
      "ps_name" => $ps_name,
      "ct_mobileno" => $ct_mobileno,
      "lineid" => $lineid
      );
    }
    // $echo_json = json_encode($sql_array);
    // echo $echo_json;
    echo json_encode($sql_array);
?>
