-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.php
142 lines (129 loc) · 5.3 KB
/
events.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
141
142
<?php
session_start();
include("config.php");
// Paging configuration
$perpage = 6; // Number sql per page
if (isset($_GET['p'])) {
$page = $_GET['p'];
} else {
$page = 1;
}
$start = ($page - 1) * $perpage;
$sql_count = "SELECT COUNT(*) AS total FROM event";
$result_count = mysqli_query($connection, $sql_count);
$row_count = mysqli_fetch_assoc($result_count);
$totaldata = $row_count['total'];
$totalpage = ceil($totaldata / $perpage);
$sql = "SELECT event.idevent, event.name
FROM `event`
LIMIT $start, $perpage;";
$result = mysqli_query($connection, $sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/assets/styles/main.css">
<link rel="stylesheet" href="/assets/styles/events.css?v= time(), ?>">
<title>Informatics E-Sport Club</title>
</head>
<body>
<!-- Top Navigation Bar -->
<header>
<nav class="topnav">
<a class="active" href="/">Homepage</a>
<a href="/teams.php">Teams</a>
<a href="/members.php">Members</a>
<a href="/events.php">Events</a>
<a href="/about.php">About Us</a>
<a href="/how-to-join.php">How to Join</a>
<?php
if (!isset($_SESSION['username'])) {
// User is not logged in
echo '<a class="active" href="/login.php">Login</a>';
} else {
// User is logged in
$displayName = "Welcome, " . $_SESSION['idmember'] . " - " . $_SESSION['username']; // Append ID and username
echo '<a class="logout" href="/logout.php" onclick="return confirmationLogout()">Logout</a>';
echo '<a class="active" href="/profile">' . htmlspecialchars($displayName) . '</a>';
// To check whether user is admin or not
if (isset($_SESSION['profile']) && $_SESSION['profile'] == 'admin') {
echo
'<div class="dropdown">
<a class="dropbtn" onclick="adminpageDropdown()">Admin Sites
<i class="fa fa-caret-down"></i>
</a>
<div class="dropdown-content" id="dd-admin-page">
<a href="/admin/teams/">Manage Teams</a>
<a href="/admin/members/">Manage Members</a>
<a href="/admin/events/">Manage Events</a>
<a href="/admin/games/">Manage Games</a>
<a href="/admin/achievements/">Manage Achievements</a>
<a href="/admin/event_teams/">Manage Event-Teams</a>
</div>
</div>';
echo
'<div class="dropdown">
<a class="dropbtn" onclick="proposalDropdown()">Join Proposal
<i class="fa fa-caret-down"></i>
</a>
<div class="dropdown-content" id="proposalPage">
<a href="/admin/proposal/waiting.php">Waiting Approval</a>
<a href="/admin/proposal/responded.php">Responded</a>
</div>
</div>';
}
}
?>
</nav>
<h1 class="hello-mssg">Hello! You can see the full list of events here.</h1>
</header>
<div class="all-member">
<?php
if ($result && mysqli_num_rows($result) > 0) {
echo "<div class='all-member'>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='container'>";
echo "<div class='content'>";
echo "<div>";
echo "<div class='title'>" . htmlspecialchars($row['name']) . "</div>";
echo "<div class='details'>" . "Event ID : " . htmlspecialchars($row['idevent']) . "</div>";
echo "</div>";
echo "<form action='event-detail.php' method='get'>";
echo "<input type='hidden' name='idevent' value='" . htmlspecialchars($row['idevent']) . "'>";
echo "<button type='submit' class='detail-button'>Details</button>";
echo "</form>";
echo "</div>";
echo "</div>";
}
echo "</div>";
} else {
echo "<div>No events found</div>";
}
?>
</div>
<!-- Paging -->
<div class="paging">
<?php
if ($page > 1) {
$prev = $page - 1;
echo "<a href='events.php?p=$prev'>Prev</a>"; // Previous page
}
for ($i = 1; $i <= $totalpage; $i++) {
if ($i == $page) {
echo "<strong>$i</strong>"; // Current page
} else {
echo "<a href='events.php?p=$i'>$i</a>"; // Other page
}
}
if ($page < $totalpage) {
$next = $page + 1;
echo "<a href='events.php?p=$next'>Next</a>"; // Next page
}
?>
</div>
<script src="/assets/js/script.js"></script>
</body>
</html>