-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventListAll.php
69 lines (52 loc) · 2.74 KB
/
eventListAll.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
//Connect to db
include_once "connect.php";
$arr[0] = 0; // Start with no results found
$count = 0;
// Check if the date variables are set
if (isset($_POST["year"]) && isset($_POST["month"]) && isset($_POST["day"]) && isset($_POST["network"])) {
$year = trim($_POST["year"]);
$month = trim($_POST["month"]);
$day = trim($_POST["day"]);
$network = trim($_POST["network"]);
$allNetworks = 'Ottawa Area';
if (strlen($month) < 2)
$month = "0" . $month;
if (strlen($day) < 2)
$day = "0" . $day;
$date = $mysqli->real_escape_string("%" . $year . "-" . $month . "-" . $day . "%"); // Get date term
if ($network == $allNetworks) {
$query = "SELECT eventid, event_title, event_picture FROM events WHERE start_date LIKE ? ORDER BY event_title";
if ($stmt = $mysqli->prepare($query)) {
$stmt->bind_param("s", $date); // Bind parameters
$stmt->execute(); // Execute statement
$stmt->bind_result($eventid, $event_title, $event_picture); // Bind result variables
/* fetch values */
while ($stmt->fetch()) {
//Get number of attendees in this event
$attendeeCount = 12;
// Create array with grid's data
$arr[$count] = array('eventid' => $eventid, 'event_title' => $event_title, 'event_picture' => $event_picture, 'attendeeCount' => $attendeeCount );
$count += 1; // Count events selected
}
}
} else {
$query = "SELECT eventid, event_title, event_picture FROM events WHERE (start_date LIKE ? AND event_network=?) OR (start_date LIKE ? AND event_network=?) ORDER BY event_title";
if ($stmt = $mysqli->prepare($query)) {
$stmt->bind_param("ssss", $date, $network, $date, $allNetworks); // Bind parameters
$stmt->execute(); // Execute statement
$stmt->bind_result($eventid, $event_title, $event_picture); // Bind result variables
/* fetch values */
while ($stmt->fetch()) {
//Get number of attendees in this event
$attendeeCount = 12;
// Create array with grid's data
$arr[$count] = array('eventid' => $eventid, 'event_title' => $event_title, 'event_picture' => $event_picture, 'attendeeCount' => $attendeeCount );
$count += 1; // Count events selected
}
}
}
}
$mysqli->close(); // Close connection
echo json_encode($arr);
?>