0){ echo "Booking successful. The resource '".$resource_name."' is booked from ".$start." to ".$end."."; } else{ echo "Mysql Error : ".mysql_error().". Query = ".$query; } } function getBookedDates() { $resource_id = $_POST['resource_id']; $query = "SELECT b.booking_id, b.resource_id,u.name as username,u.email,b.starttime,b.endtime,b.creation,b.purpose FROM booking as b,user as u WHERE b.resource_id=".$resource_id." AND b.user_id=u.user_id;"; $result = mysql_query($query); $events = array(); while ($row = mysql_fetch_array($result)) { $e = array(); $e['id'] = $row['booking_id']; $e['booker_name'] = $row['username']; $e['booker_email'] = $row['email']; $e['title'] = $row['purpose']; $e['start'] = $row['starttime']; $e['end'] = $row['endtime']; $e['bookdate'] = $row['creation']; // Merge the event array into the return array array_push($events, $e); } echo json_encode($events); } $action = $_POST['action']; connectDB(); if ($action == "book") { book(); } elseif ($action == "getBookedDates" ) { getBookedDates(); } else { echo "Invalid POST action."; } closeDB(); ?>