-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewmyevents.php
140 lines (115 loc) · 4.26 KB
/
viewmyevents.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
//check if you are login
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}
?>
<?php
//connect to database
$connection1=mysqli_connect("localhost","root", "", "clubhub");
$connection2=mysqli_connect("localhost","root", "", "clubhub");
$connection3=mysqli_connect("localhost","root", "", "clubhub");
$connection4=mysqli_connect("localhost","root", "", "clubhub");
$connection5=mysqli_connect("localhost","root", "", "clubhub");
if(mysqli_connect_errno()){
die("Database connection fail: ".mysqli_connect_error(). " (" .mysqli_connect_errno().")");
}
?>
<?php
//create query
//query to get the clubid of the club the person is in.
$club = $connection1->prepare("(SELECT clubID FROM person natural join member_of WHERE pid=?)
UNION (SELECT clubID FROM person natural join advisor_of WHERE pid=?)");
$club->bind_param("ss", $personId, $personId);
$personId = "1";
$club->bind_result($clubId);
//query to get event that the person signed up
$querySignUp = "SELECT distinct ename, edatetime, location, sponsored_by FROM sign_up natural join event WHERE pid=? and ";
$querySignUp.= "edatetime>= curdate()";
$signedUp = $connection2->prepare($querySignUp);
$signedUp->bind_param("s", $personId);
$signedUp->bind_result($ename, $edatetime, $location, $sponsored_by);
//query to get event for the current day and the next three day that is public.
$queryPublicEvent = "SELECT distinct ename, edatetime, location, sponsored_by FROM event WHERE is_public_e=1 and ";
$queryPublicEvent.= "edatetime BETWEEN curdate() and (Curdate() + interval 3 day) and ";
$queryPublicEvent.= "(ename, edatetime, location, sponsored_by) NOT IN(" . $querySignUp . ")";
$publicEvent = $connection3->prepare($queryPublicEvent);
$publicEvent->bind_param("s", $personId);
$publicEvent->bind_result($pEname, $pEdatetime, $pLocation, $pSponsored_by);
//query to get event for the current day and the next three day that is sponsored by your club.
$queryOtherEvent = "SELECT distinct ename, edatetime, location, sponsored_by FROM event WHERE is_public_e=0 and sponsored_by=? and ";
$queryOtherEvent.= "edatetime BETWEEN curdate() and (Curdate() + interval 3 day) and ";
$queryOtherEvent.= "(ename, edatetime, location, sponsored_by) NOT IN(" . $querySignUp . ")";
$otherEvent = $connection4->prepare($queryOtherEvent);
$otherEvent->bind_param("is", $checkClubid, $personId);
$otherEvent->bind_result($oEname, $oEdatetime, $oLocation, $oSponsored_by);
//query to get sponsor name.
$sponsor = $connection5->prepare("SELECT cname FROM club WHERE clubid=?");
$sponsor->bind_param("s", $eventSponsor);
$sponsor->bind_result($cname);
?>
<div>
<h1> Events </h1>
</div>
<div>
<h4> Event(s) you have already signed up for: </h4><hr>
</div>
<?php
$signedUp->execute();
while($signedUp->fetch()){
echo 'Event name: ' . $ename . "</br>";
echo 'Datetime: ' . $edatetime . "</br>";
echo 'Location: ' . $location . "</br>";
$eventSponsor = $sponsored_by;
$sponsor->execute();
if($sponsor->fetch()){
echo 'Sponsored By: ' . $cname . "</br><hr/>";
}
}
?>
<div>
<h4> Event(s) for the current day and the next three day that you can sign up for: </h4><hr>
</div>
<?php
$publicEvent->execute();
while($publicEvent->fetch()){
echo 'Event name: ' . $pEname . "</br>";
echo 'Datetime: ' . $pEdatetime . "</br>";
echo 'Location: ' . $pLocation . "</br>";
$eventSponsor = $pSponsored_by;
$sponsor->execute();
if($sponsor->fetch()){
echo 'Sponsored By: ' . $cname . "</br><hr/>";
}
}
$club->execute();
while($club->fetch()){
$clubID=$checkClubid;
$otherEvent->execute();
while($otherEvent->fetch()){
echo"hello22222";
echo 'Event name: ' . $ename . "</br>";
echo 'Datetime: ' . $edatetime . "</br>";
echo 'Location: ' . $location . "</br>";
$eventSponsor = $oSponsored_by;
$sponsor->execute();
if($sponsor->fetch()){
echo 'Sponsored By: ' . $cname . "</br><hr/>";
}
}
}
?>
<?php
$club->close();
$signedUp->close();
$publicEvent->close();
$otherEvent->close();
$sponsor->close();
mysqli_close($connection1);
mysqli_close($connection2);
mysqli_close($connection3);
mysqli_close($connection4);
mysqli_close($connection5);
?>
<a href="logout.php">logout</a> <br>