-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.php
More file actions
170 lines (143 loc) · 7.06 KB
/
Copy pathevents.php
File metadata and controls
170 lines (143 loc) · 7.06 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php include('server.php') ?>
<?php
if(isset($_SESSION['mobile'])){ // checks if the user is logged in
}
else{
header("location: index.php"); // redirects if user is not logged in
}
?>
<?php
if (isset($_GET['book'])) {
$concert_id = $_GET['book'];
$count = mysqli_query($db, "SELECT * FROM concert WHERE concert_id=$concert_id");
if (isset($count->num_rows) && $count->num_rows > 0 ) {
$n = mysqli_fetch_array($count);
$concert_date = $n['concert_date'];
$concert_band = $n['band_id'];
$concert_venue = $n['venue_id'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include 'header.php';?>
<body>
<h4>Welcome to Free-Gigs,the Free Concert Website</h4>
<div class="wrapper">
<header>
<p><strong><?php echo $_SESSION['firstname']; ?></strong></p>
</header>
<section>
<nav>
<ul>
<h4><a href="events.php">Booking Area </a></h4>
<!-- notification message -->
<p><strong>Welcome <?php echo $_SESSION['firstname']; ?></strong></p>
<p> <a href="logout.php" style="color: red;">logout</a> </p>
</ul>
</nav>
<div id="content-wrap">
<div id="info-wrap">
<div class="info">
<h3>Upcoming Concerts</h3>
<form action="events.php?book=<?php echo $row['concert_id']; ?>" method="post">
<?php include('errors.php'); ?>
<!-- <input type="hidden" name="concert_id" value="<?php echo $concert_id; ?>"> -->
<?php $results = mysqli_query($db, "SELECT c.concert_id,c.concert_date,v.venue_name,v.venue_capacity,v.venue_id,b.band_id,b.band_name FROM concert as c JOIN venue v ON c.venue_id = v.venue_id JOIN band as b WHERE c.band_id = b.band_id"); ?>
<table class="table-sm text-center">
<thead>
<tr>
<th>Date</th>
<th>Band</th>
<th>Venue</th>
<th>Capacity</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_array($results)) {
if (strtotime($row['concert_date']) > time()) {
?>
<tr>
<input type="hidden" name="concert_id" value="<?php echo $row['concert_id']; ?>">
<td><?php echo $row['concert_date']; ?></td>
<input type="hidden" name="concert_date" value='<?php echo $row['concert_date'] ?>'>
<td><?php echo $row['band_name']; ?></td>
<input type="hidden" name="concert_band" value='<?php echo $row['concert_band'] ?>'>
<td><?php echo $row['venue_name']; ?></td>
<input type="hidden" name="concert_venue"
value='<?php echo $row['concert_venue'] ?>'>
<td>
<?php
$count = mysqli_query($db,"SELECT count('booking_id') FROM booking WHERE concert_id=".$row['concert_id']."");
while($row1 = mysqli_fetch_array($count)){
echo "$row1[0]";
}
?> /
<?php echo $row['venue_capacity']?>
</td>
<td>
<?php
$count = mysqli_query($db,"SELECT count('booking_id') FROM booking WHERE concert_id=".$row['concert_id']."");
while($row1 = mysqli_fetch_array($count)){
if($row1[0] == $row['venue_capacity']){
echo "Fully booked";
}
else{
echo "<a href='events.php?book=".$row['concert_id']."' class='btn'
name='book' type='submit'>book</a>";
}
}
?>
</td>
</tr>
<?php
}
}
?>
</table>
</form>
</div>
</div>
<!--booking a concert-->
<div class="info">
<h3> My Bookings</h3>
<?php
$user_id=$_SESSION['user_id'];
$results = mysqli_query($db, "SELECT bk.booking_id,c.concert_date,b.band_name,v.venue_name FROM booking as bk JOIN users as u ON bk.user_id=u.user_id JOIN concert as c JOIN venue v ON c.venue_id = v.venue_id JOIN band as b ON c.band_id = b.band_id ON bk.concert_id = c.concert_id WHERE u.user_id=$user_id"); ?>
<table>
<thead>
<tr>
<th>Date</th>
<th>Band</th>
<th>Venue</th>
<th colspan="2">Action</th>
</tr>
</thead>
<?php while ($row = mysqli_fetch_array($results)) {
if (strtotime($row['concert_date']) > time()) {
?>
<tr>
<td><?php echo $row['concert_date']; ?></td>
<td><?php echo $row['band_name']; ?></td>
<td><?php echo $row['venue_name']; ?></td>
<td>
<a href="events.php?cancel=<?php echo $row['booking_id']; ?>"
onclick="return confirm('Are you sure you want to cancel?')"
class="edit_btn">cancel</a>
</td>
</tr>
<?php
}
}
?>
</table>
</div>
</div>
</section>
<footer>
<p>Free-Gigs <?php echo date("Y");?></p>
</footer>
</div>
</body>
</html>