get_results("select * from $wpdb->prefix"."apt_appointments");
$num_rows=count($ap_fecth);
if($num_rows !==0) {
foreach($ap_fecth as $value) {
$id=$value->id;
$client_email=$value->client_email;
$client_name=$value->client_name;
if( empty($client_name) ) {
$client_name = $client_email;
}
$staff_member=$value->staff_member;
$ap_fecth_staff=$wpdb->get_results("select * from $wpdb->prefix"."apt_staff where id='$staff_member'");
foreach($ap_fecth_staff as $ap_fecth_single_staff) {
$staff_name= $ap_fecth_single_staff->staff_member_name;
$staff_email= $ap_fecth_single_staff->staff_email;
}
$service_type=$value->service_type;
$contact =$value->contact ;
$booking_date=$value->booking_date ;
$start_time =$value->start_time ;
$end_time=$value->end_time;
$status=$value->status;
$results["data"][] =array('',$id,array($booking_date,$start_time,"To",$end_time),$client_name,$service_type,
'',
$contact,array('   '));
}
} else {
$results["data"][] =array(null,null,null,'No appointment Add',null,null,null,null);
}
if($results != null) {
wp_send_json($results); // encode and send response
} else {
wp_send_json_error(); // {"success":false}
}
?>