-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkclubevent.php
55 lines (48 loc) · 1.46 KB
/
checkclubevent.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
<?php
//check if you are login
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}
//get user id
$userid= $_SESSION['userName'];
?>
<?php
//connect to database
$connection=mysqli_connect("localhost","root", "", "clubhub");
$connection2=mysqli_connect("localhost","root", "", "clubhub");
if(mysqli_connect_errno()){
die("Database connection fail: ".mysqli_connect_error(). " (" .mysqli_connect_errno().")");
}
?>
<?php
//create query
$checkAdmin = $connection->prepare("SELECT clubid FROM role_in WHERE pid=? and role='Admin'");
$checkAdmin->bind_param("i", $userid);
$checkAdmin->execute();
$checkAdmin->bind_result($clubid);
if(!$checkAdmin){
die("Database checkAdmin query access fail");
};
$showEvent = $connection2->prepare("SELECT eid, ename, sponsored_by, count(pid) FROM event natural join sign_up WHERE sponsored_by=? GROUP BY eid");
$showEvent->bind_param("i", $sponsorID);
?>
<h1>Event Check </h1>
<?php
while($checkAdmin->fetch()){
echo 'clubID: ' . $clubid . "</br>";
$sponsorID=$clubid;
$showEvent->execute();
$showEvent->bind_result($eid, $ename, $sponsored_by, $count);
while($showEvent->fetch()){
echo 'Eid: ' . $eid . "</br>";
echo 'Ename: ' . $ename . "</br>";
echo 'Sponsored By: ' . $sponsored_by . "</br>";
echo 'Amount that signed up: ' . $count . "</br><hr/>";
}
}
?>
<?php
mysqli_close($connection);
?>
<a href="logout.php">logout</a> <br>