<?php include('includes/config/config.php'); error_reporting(E_ERROR | E_PARSE); $Id = $_REQUEST['guest_id']; $query = "select health_score,checkup_date from guest_checkup_form where guest_id ='".$Id."' order by checkup_date asc limit 6"; //echo $query; if (!$result = @mysqli_query($conn,$query )) { die(mysqli_error($conn)); } $data = array(); $x=0; if(mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { // $data[$x] = $row; //$data[]=$row; //$x++; //$data[$x]=$row; $data[$x]['health_score']=$row['health_score']; $data[$x]['checkup_date']=date_format(date_create($row['checkup_date']),"d-M-Y"); $x++; } } else { $data['status'] = 200; $data['message'] = "Data not found!"; } echo json_encode($data); ?>