-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewEvents.php
More file actions
37 lines (35 loc) · 993 Bytes
/
viewEvents.php
File metadata and controls
37 lines (35 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
header("Content-Type: application/json");
//This will store the data into an associative array
$mysqli= new mysqli('localhost', 'mod5','Kelly38538a!','module5');
if ($mysqli->connect_errno){
printf("Connection Failed: %s\n", $mysqli->connect_error);
exit;
}
session_start();
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str, true);
$date=$json_obj['date'];
$owner=true;
$user=$_SESSION['username'];
$stmt = $mysqli->prepare("select eventName, startTime,owner, eventId,tag from events where user=? AND eventDate=STR_TO_DATE(?,'%m/%d/%Y') ORDER BY startTime asc");
$stmt->bind_param('ss', $_SESSION['username'],$date);
$stmt->execute();
$res=$stmt->get_result();
$events=array();
while ($row1=$res->fetch_assoc()){
array_push($events,$row1);
}
if(!$stmt){
echo json_encode(array(
"success" => false,
"message" => "Failed to add event"
));
exit;
}
$stmt->close();
echo json_encode(array(
"success"=>true,
"events"=>$events
));
?>