while ($row = $data->fetch(PDO::FETCH_ASSOC)) { $e = array(); extract($row); $p = $phone; $u = $first_name . ' ' . $last_name; } $p = explode('0', $p, 2); sms("+254" . $p[1], "Dear {$u}, Your next appointment will be on " . date('d M, Y h:i A', strtotime($appointments->startdate))); echo json_encode(array('status' => 'success')); } else { echo json_encode(array('status' => 'failed')); } exit; break; case 'fetch': $stmt = $appointments->readAll(); $app = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $e = array(); extract($row); $e['id'] = $id; $e['title'] = $title; $e['user_id'] = $user_id; $e['start'] = $startdate; $e['end'] = $enddate; $allday = $allDay == "true" ? true : false; $e['allDay'] = $allday; array_push($app, $e); } //header('Content-Type: application/json'); echo json_encode($app);