-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamepagedetailed.php
579 lines (504 loc) · 18.9 KB
/
gamepagedetailed.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
<?php
// Connect to database
// TODO: add like/unlike button
include "dbconnection.php";
session_start();
// Get game ID from URL (example: reviews.php?game_id=1)
$game_id = isset($_GET['game_id']) ? (int)$_GET['game_id'] : 0;
$user_id = $_SESSION['user_id'] ?? null;
// Check if game_id is valid
if ($game_id <= 0) {
die("Please provide a valid game ID");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Details for Game | Echolog</title>
<meta name="description" content="Track your games, share your thoughts, build your collection">
<link rel="stylesheet" href="style.css">
<style>
.container {
padding-top: 2rem;
max-width: 1200px;
margin: 0 auto;
}
.game-info {
background-color: transparent;
/* padding: 20px; */
margin-bottom: 20px;
border-radius: 8px;
/* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); */
}
.game-info img {
max-width: 200px;
border-radius: 8px;
}
.review {
background-color: #2a3b4d;
padding: 20px;
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.user-info {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.user-info img {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
}
.rating {
color: gold;
font-weight: bold;
font-size: 1.2em;
}
.date {
color: #999;
font-size: 0.9em;
}
.review-card {
display: flex;
flex-direction: row;
gap: 1rem;
padding: 1.5rem;
border-radius: 1.5rem;
background-color: #3b3b48;
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.5);
width: 50%;
}
.review-card__left {
width: 100px;
}
.review-card__game-image {
width: 100%;
height: 100%;
border-radius: 1.5rem;
object-fit: cover;
}
.review-card__game-image.alt {
border-radius: 50px;
height: auto;
aspect-ratio: 1/1;
}
.review-card__right {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
width: 100%;
}
.review-card__right>* {
margin: 0;
}
p.review-card__game-title {
font-size: 2.5rem;
line-height: 1.2;
}
p.review-card__adjoining-info {
font-size: 1.25rem;
color: #c1c1c1;
}
span.review-card__rating {
color: var(--color-review);
}
.review-card__rating-alt:not(.alt) {
display: none;
}
p.review-card__text {
font-size: 1.5rem;
line-height: 1.5;
margin-top: 1rem;
color: #c1c1c1;
}
.review-card__like-info {
display: flex;
flex-direction: row;
gap: 0.5rem;
flex: 1;
justify-content: flex-end;
align-items: flex-end;
width: 100%;
height: 100%;
cursor: pointer;
}
a.review-card__like-button {
display: flex;
flex-direction: row;
gap: 0.5rem;
align-items: center;
color: #c1c1c1;
text-decoration: none;
}
img.review-card__like-icon {
width: 2rem;
height: 2rem;
transition: transform 0.2s;
}
img.review-card__like-icon:hover {
transform: scale(1.1);
}
span.review-card__like-count {
font-size: 1.5rem;
color: #c1c1c1;
user-select: none;
}
.collection-card {
display: flex;
flex-direction: column;
width: 100%;
max-width: 400px;
height: 100%;
overflow: hidden;
transition: transform 0.2s;
}
.collection-card.alt {
flex-direction: row;
max-width: 100%;
}
.collection-card:hover,
.collection-card:focus {
transform: translateY(-0.5rem);
}
a.collection-card--hidden {
display: none;
}
div.collection-card__image-frame {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
aspect-ratio: 3 / 2;
margin-bottom: 0.4rem;
}
div.collection-card__image-frame.alt {
max-width: 300px;
}
div.collection-card__overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 0.5rem;
padding: 1rem;
transition: opacity 0.2s;
}
img.collection-card__image {
position: absolute;
top: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
div.collection-card__image--1 {
max-width: 200px;
left: 0;
z-index: 500;
}
div.collection-card__image--2 {
max-width: 200px;
left: 25px;
z-index: 400;
}
div.collection-card__image--3 {
max-width: 200px;
left: 50px;
z-index: 300;
}
div.collection-card__image--4 {
max-width: 200px;
left: 75px;
z-index: 200;
}
div.collection-card__image--5 {
max-width: 200px;
left: 100px;
z-index: 100;
}
p.collection-card__title {
line-height: 1.2;
font-weight: 700;
color: #fff;
}
p.collection-card__info {
font-size: 1.4rem;
color: #c1c1c1;
}
span.collection-card__username {
font-weight: 700;
}
.collections {
display: flex;
flex-direction: row;
gap: 1rem;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
</style>
</head>
<body>
<header class="header">
<a class="header__logo" href="/echolog/">
<img src="/echolog/assets/svgs/logo.svg" alt="My Website Logo" />
</a>
<nav class="header__nav">
<a class='header__nav-link' href='/echolog/BrowseGames.php'>Games</a>
<a class='header__nav-link' href='/echolog/BrowsePlaylist.php'>Collections</a>
<a class='header__nav-link' href='/echolog/profile.php'>Profile</a>
</nav>
<a class="header__login" href="/echolog/login.php">Login</a>
</header>
<main>
<div class="container">
<?php
// First, get game information
$game_sql = "SELECT game_title, cover_image FROM Games WHERE game_id = ?";
$game_stmt = $conn->prepare($game_sql);
$game_stmt->bind_param("i", $game_id);
$game_stmt->execute();
$game = $game_stmt->get_result()->fetch_assoc();
// Display game information
if ($game) {
echo "<div class='game-info'>";
echo "<h1>" . htmlspecialchars($game['game_title']) . "</h1>";
if ($game['cover_image']) {
echo "<img src='" . htmlspecialchars($game['cover_image']) . "' alt='Game Cover'>";
}
echo "</div>";
}
// Get all reviews for this game
$review_sql = "
SELECT
r.review_text,
r.created_at,
r.like_count,
u.user_nickname,
u.profile_image,
rt.rating
FROM Reviews r
JOIN Users u ON r.user_id = u.user_id
LEFT JOIN Ratings rt ON (r.game_id = rt.game_id AND r.user_id = rt.user_id)
WHERE r.game_id = ?
ORDER BY r.created_at DESC
";
$review_stmt = $conn->prepare($review_sql);
$review_stmt->bind_param("i", $game_id);
$review_stmt->execute();
$reviews = $review_stmt->get_result();
$liked_user = "
SELECT
l.user_id,
u.user_nickname,
u.profile_image
FROM Likes_Games l
JOIN Users u ON l.user_id = u.user_id
Where l.game_id = ?
";
$liked_stmt = $conn->prepare($liked_user);
$liked_stmt->bind_param("i", $game_id);
$liked_stmt->execute();
$likes = $liked_stmt->get_result();
$wishlisted_user = "
SELECT
w.user_id,
u.user_nickname,
u.profile_image
FROM WISHLIST w
JOIN Users u ON w.user_id = u.user_id
Where w.game_id = ?
";
$wish_stmt = $conn->prepare($wishlisted_user);
$wish_stmt->bind_param("i", $game_id);
$wish_stmt->execute();
$wishes = $wish_stmt->get_result();
$stmt = $conn->prepare("
SELECT
p.playlist_id,
p.playlist_name,
p.playlist_description,
p.user_id AS creator_id,
u.user_nickname AS creator_name,
COUNT(lp.user_id) AS like_count,
g.cover_image AS game_cover_image
FROM
Playlist p
LEFT JOIN
Playlist_Games pg ON p.playlist_id = pg.playlist_id
LEFT JOIN
Games g ON pg.game_id = g.game_id
LEFT JOIN
Likes_Playlists lp ON p.playlist_id = lp.playlist_id
LEFT JOIN
Users u ON p.user_id = u.user_id
WHERE
pg.game_id = ?
GROUP BY
p.playlist_id
ORDER BY
like_count DESC, p.playlist_name ASC
");
$stmt->bind_param("i", $game_id);
$stmt->execute();
$result = $stmt->get_result();
// Display reviews
if ($reviews->num_rows > 0) {
while ($review = $reviews->fetch_assoc()) {
// echo "<div class='review'>";
// // User info section
// echo "<div class='user-info'>";
// if ($review['profile_image']) {
// echo "<img src='" . htmlspecialchars($review['profile_image']) . "' alt='Profile'>";
// }
// echo "<div>";
// echo "<h3>" . htmlspecialchars($review['user_nickname']) . "</h3>";
// echo "<span class='date'>" . date('F j, Y', strtotime($review['created_at'])) . "</span>";
// echo "<p>" . (int)htmlspecialchars($review['like_count']) . "</p>";
// echo "</div>";
// echo "</div>";
// // Review content
// echo "<p>" . nl2br(htmlspecialchars($review['review_text'])) . "</p>";
// // Show rating if exists
// if ($review['rating']) {
// echo "<div class='rating'>Rating: " . htmlspecialchars($review['rating']) . "/5 ⭐</div>";
// }
echo "<div class='review-card mb-3'>";
echo "<div class='review-card__left'>";
echo "<img class='review-card__game-image alt' src='" . $review['profile_image'] . "' alt='" . $review['user_nickname'] . "' />";
echo "<p class='m-0 text-center fs-1-2'>" . $review['user_nickname'] . "</p>";
echo "</div>";
echo "<div class='review-card__right'>";
if ($review['rating']) {
echo "<p class='review-card__rating m-0'><span>" . $review['rating'] . "</span>/5</p>";
}
echo "<p class='review-card__text m-0'>" . $review['review_text'] . "</p>";
echo "<div class='review-card__like-info'>";
echo "<a class='review-card__like-button'>";
echo "<img class='review-card__like-icon' src='/echolog/assets/svgs/heart-outline.svg' alt='Like Icon' />";
echo "<span class='review-card__like-count'>" . $review['like_count'] . "</span>";
echo "</a>";
echo "</div>";
echo "</div>";
echo "</div>";
}
} else {
echo "<div class='review'>No reviews yet for this game.</div>";
}
echo "<h2>People who Liked</h2>";
if ($likes->num_rows > 0) {
while ($like = $likes->fetch_assoc()) {
echo "<div class='review'>";
// User info section
echo "<div class='user-info'>";
if ($like['profile_image']) {
echo "<img src='" . htmlspecialchars($like['profile_image']) . "' alt='Profile'>";
}
echo "<div>";
echo "<h3>" . htmlspecialchars($like['user_nickname']) . "</h3>";
// echo "<span class='date'>" . date('F j, Y', strtotime($review['created_at'])) . "</span>";
// echo "<p>" . (int)htmlspecialchars($review['like_count']) ."</p>";
echo "</div>";
echo "</div>";
echo "</div>";
}
} else {
echo "<div class='review'>No likes for this game.</div>";
}
echo "<h2>People who Wishlisted</h2>";
if ($wishes->num_rows > 0) {
while ($wish = $wishes->fetch_assoc()) {
echo "<div class='review'>";
// User info section
echo "<div class='user-info'>";
if ($wish['profile_image']) {
echo "<img src='" . htmlspecialchars($wish['profile_image']) . "' alt='Profile'>";
}
echo "<div>";
echo "<h3>" . htmlspecialchars($wish['user_nickname']) . "</h3>";
echo "</div>";
echo "</div>";
echo "</div>";
}
} else {
echo "<div class='review'>No wishes for this game :( </div>";
}
echo "<h2>Playlist that contains this game</h2>";
if ($result->num_rows > 0) {
echo "<div class='collections'>";
while ($row = $result->fetch_assoc()) {
// Fetch and sanitize data
$playlist_id = $row['playlist_id'];
$playlist_name = htmlspecialchars($row['playlist_name']);
$playlist_description = htmlspecialchars($row['playlist_description']);
$creator_name = htmlspecialchars($row['creator_name']);
$like_count = (int) $row['like_count'];
$cover_image = htmlspecialchars($row['game_cover_image']);
// // Display each playlist
// echo "<div style='border: 1px solid #ccc; padding: 10px; margin-bottom: 15px;'>";
// echo "<h3>$playlist_name</h3>";
// echo "<p><strong>Created by:</strong> $creator_name</p>";
// echo "<p><strong>Description:</strong> $playlist_description</p>";
// echo "<p><strong>Likes:</strong> $like_count</p>";
// if ($cover_image) {
// echo "<img src='$cover_image' alt='Game Cover' style='width: 100px; height: 100px; object-fit: cover;'>";
// }
// echo "</div>";
// echo "<a href='playlist_view.php?playlist_id=$playlist_id'>View</a>";
echo "<a href='playlist_view.php?playlist_id=$playlist_id' class='collection-card alt'>";
echo "<div class='collection-card__image-frame alt'>";
echo "<div class='collection-card__overlay collection-card__image--1'>";
echo "<img class='collection-card__image collection-card__image--1' src='/echolog/assets/images/list-1.png' alt='$playlist_name' />";
echo "</div>";
echo "<div class='collection-card__overlay collection-card__image--2'>";
echo "<img class='collection-card__image collection-card__image--2' src='/echolog/assets/images/list-2.png' alt='$playlist_name' />";
echo "</div>";
echo "<div class='collection-card__overlay collection-card__image--3'>";
echo "<img class='collection-card__image collection-card__image--3' src='/echolog/assets/images/list-3.png' alt='$playlist_name' />";
echo "</div>";
echo "<div class='collection-card__overlay collection-card__image--4'>";
echo "<img class='collection-card__image collection-card__image--4' src='/echolog/assets/images/list-4.png' alt='$playlist_name' />";
echo "</div>";
echo "<div class='collection-card__overlay collection-card__image--5'>";
echo "<img class='collection-card__image collection-card__image--5' src='/echolog/assets/images/list-5.png' alt='$playlist_name' />";
echo "</div>";
echo "</div>";
echo "<div class='pl-1'>";
echo "<p class='collection-card__title fs-2 m-0'>$playlist_name</p>";
echo "<p class='collection-card__info m-0'>";
echo "<span class='collection-card__username'>$creator_name</span>";
echo "<span> | </span>";
echo "<span>$like_count likes</span>";
echo "</p>";
echo "<p class='gray m-0'>$playlist_description</p>";
echo "</div>";
echo "</a>";
}
echo "</div>";
} else {
echo "<p>No playlists found containing this game.</p>";
}
// Close database connections
$game_stmt->close();
$review_stmt->close();
$liked_stmt->close();
$wish_stmt->close();
$stmt->close();
?>
</div>
</main>
<footer class="footer mt-5">
<p class="footer__text">© 2025 Echolog. All rights reserved.</p>
</footer>
</body>
</html>