-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
151 lines (141 loc) · 6.3 KB
/
Copy pathindex.php
File metadata and controls
151 lines (141 loc) · 6.3 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
<?php
session_start();
include 'config/db.php';
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="assets/css/style.css">
<title>Event Booking Site - Financial Seminars</title>
<style>
body { font-family: sans-serif; padding: 20px; background-color: #111827; color: #e5e7eb; }
.nav { background: #1F2937; padding: 10px; color: #e5e7eb; margin-bottom: 20px; border-radius: 8px; }
.nav a { color: #e5e7eb; margin-right: 15px; text-decoration: none; }
.event-card {
border: 1px solid #ddd;
padding: 10px;
border-radius: 8px;
background: #1F2937;
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
transition: box-shadow 0.2s, transform 0.2s;
cursor: pointer;
width: 100%;
color: #e5e7eb;
display: flex;
flex-direction: column;
}
.event-card:hover {
box-shadow: 0 8px 24px rgba(44, 62, 80, 0.18);
transform: translateY(-4px) scale(1.02);
border-color: #8B5CF6;
}
.event-card .body {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.events-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 15px;
}
.search-box { padding: 15px; background: #1F2937; margin-bottom: 20px; color: #e5e7eb; border-radius: 8px; }
.search-box input, .search-box select { background: #111827; color: #e5e7eb; border: 1px solid #9CA3AF; padding: 5px; }
.search-box button { background: linear-gradient(135deg, #6366f1, #22d3ee); color: #040025; border: none; padding: 8px 12px; cursor: pointer; }
.search-box button:hover { transform: translateY(-2px); }
</style>
</head>
<body>
<div class="nav">
<strong style="margin-right: 20px;">Event Booking Site</strong>
<ul style="list-style:none; display:inline; padding: 10px; margin: 10px;">
<a href="index.php">Home</a>
<?php if(isset($_SESSION['user_id'])): ?>
<a href="my_bookings.php">My Tickets</a>
<a href="admin/add_event.php">Post Event</a>
<?php if($_SESSION['role'] == 'admin'): ?>
<a href="admin/dashboard.php">Admin Dashboard</a>
<?php endif; ?>
<a href="logout.php" style="float:right;">Logout (<?php echo $_SESSION['username']; ?>)</a>
<?php else: ?>
<a href="login.php" style="float:right;">Login / Register</a>
<?php endif; ?>
</ul>
</div>
<div class="search-box">
<form method="GET" action="index.php">
<input type="text" name="search" placeholder="Search event name..." value="<?php echo isset($_GET['search']) ? $_GET['search'] : ''; ?>">
<select name="category">
<option value="">All Categories</option>
<option value="Stock Market">Stock Market</option>
<option value="Crypto">Crypto</option>
<option value="Real Estate">Real Estate</option>
<option value="Banking">Banking</option>
<option value="Finance">Finance</option>
<option value="Networking">Networking</option>
<option value="Technology">Technology</option>
<option value="Career Guidance">Career Guidance</option>
</select>
<button type="submit">Search</button>
</form>
</div>
<?php
// Dynamic Query Builder for Search
$sql = "SELECT * FROM events WHERE 1=1";
$params = [];
if (isset($_GET['search']) && !empty($_GET['search'])) {
$sql .= " AND title LIKE ?";
$params[] = '%' . $_GET['search'] . '%';
}
if (isset($_GET['category']) && !empty($_GET['category'])) {
$sql .= " AND category = ?";
$params[] = $_GET['category'];
}
$sql .= " ORDER BY event_date DESC";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$result = $stmt;
?>
<div class="container" style="background-color:#1F2937;">
<div class="card">
<h1 style="color: #e5e7eb;">Available Events</h1>
<?php if ($result->rowCount() > 0) {
echo "<div class='events-grid'>";
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$event_id_loop = $row['id'];
$review_stmt = $conn->prepare("SELECT AVG(rating) as avg_rating FROM reviews WHERE event_id = ?");
$review_stmt->execute([$event_id_loop]);
$rev = $review_stmt->fetch(PDO::FETCH_ASSOC);
$avg_rating = $rev['avg_rating'] ? round($rev['avg_rating'],1) : '4.5';
$att_stmt = $conn->prepare("SELECT COUNT(*) as attendees FROM bookings WHERE event_id = ?");
$att_stmt->execute([$event_id_loop]);
$att = $att_stmt->fetch(PDO::FETCH_ASSOC);
$attendees = $att['attendees'];
echo "<div class='event-card' onclick=\"window.location.href='view_event.php?id=" . $row['id'] . "'\">";
$img = !empty($row['image_path']) ? $row['image_path'] : 'uploads/1769186605_photo.avif';
echo "<div class='event-media' style=\"background-image: url('" . $img . "');\">";
echo "<span class='tag'>" . htmlspecialchars($row['category']) . "</span>";
echo "<span class='fav'>♥</span>";
echo "<div class='rating'>★ " . $avg_rating . "</div>";
echo "</div>";
echo "<div class='body'>";
echo "<h3>" . htmlspecialchars($row['title']) . "</h3>";
$venue_text = (isset($row['location_url']) && !empty($row['location_url'])) ? 'Venue' : '';
echo "<div class='meta'>" . ($attendees > 0 ? $attendees . "+" : "0") . " • " . $venue_text . "</div>";
echo "<div class='footer' style='display:flex; justify-content:space-between; align-items:center; margin-top:auto; padding-top:10px;' >";
echo "<div class='price'>₹" . number_format($row['price']) . "</div>";
echo "<button class='cta' onclick=\"window.location.href='view_event.php?id=" . $row['id'] . "'\">Book Now</button>";
echo "</div>";
echo "</div>";
echo "</div>";
}
echo "</div>";
} else {
echo "<p>No seminars found. Try a different search.</p>";
}
?>
</div>
</div>
</div>
</body>
</html>