forked from chriszhou1992/ABCD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowLiked.php
More file actions
56 lines (43 loc) · 1.35 KB
/
Copy pathshowLiked.php
File metadata and controls
56 lines (43 loc) · 1.35 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
<?php
session_start();
$username = $_SESSION["user"];
require_once "classes/connecToDB.php";
$con = connectToDB();
if($con === false):
return;
endif;
$sql = "SELECT gamesLiked FROM users WHERE email = '$username'";
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
$row = mysqli_fetch_array($result);
$gamesLiked = $row['gamesLiked'];
$gamesLiked = explode("<br>", $gamesLiked);
$gamesLiked = array_slice($gamesLiked, 1);
$bound = count($gamesLiked);
if($bound ===0):
echo "<div class='alert alert-white'><i class='fa fa-crosshairs'></i>  Your collection is empty because you have not liked any game yet!</div>";
return;
endif;
$count = 0;
foreach($gamesLiked as $game):
$sql = "SELECT * FROM games where name = '$game'";
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
$row = mysqli_fetch_array($result);
$imageSrc = $row['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $row['name'];
$send = str_replace("'", "!-!-!", $name);
echo "<span class='games' name='$send'>$name</span><hr>";
$brief = $row['brief'];
if($count+1 === $bound) {
echo "$brief";
} else {
echo "$brief<hr>";
}
$count += 1;
endforeach;