-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.php
135 lines (112 loc) · 4.71 KB
/
category.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
<?php
session_start();
if (!isset($_SESSION['username'])) {
session_destroy();
}
require_once('mysqli_connect.php');
if (isset($_GET['id']) && !empty($_GET['id'])) {
$categoryId = $_GET['id'];
}
else {
// redirect to home page
header('Location: index.php');
}
if (!empty($categoryId)) {
$query = "SELECT category_name FROM category WHERE categoryId = $categoryId";
$response = @mysqli_query($dbc, $query);
if ($response) {
$category = mysqli_fetch_assoc($response);
$categoryName = $category['category_name'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="resources/css/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="resources/js/script.js"></script>
<title>Category - <?php echo $categoryName ?></title>
</head>
<body>
<nav id="nav">
<div class="main-header">
<a href="index.php"><img class="nav-logo" src="resources/images/logo.png"></a>
<?php
if (isset($_SESSION['fullname'])) {
echo
'<div class="nav-user">' .
'<h3 class="fullname">' . $_SESSION['fullname'] . '</h3>' .
'<div id="logout">' .
'<h4 style="color: white;" onclick='."'window.location.href=".'"logout.php"'."'>Logout</h4>" .
'</div>' .
'</div>';
}
else if (!isset($_SESSION['fullname'])) {
echo
'<div class="nav-login">' .
'<ul>' .
'<li><button class="button primary-btn" onclick="location.href=' . "'login.php'" . '">Sign In</button></li>' .
'<li><button class="button secondary-btn" onclick="location.href=' . "'register.php'" . '">Sign Up</button></li>' .
'</ul>' .
'</div>';
}
?>
</div>
</nav>
<div class="subheader category">
<div class="container">
<h1><?php echo $categoryName ?></h1>
</div>
</div>
<div class="movie-list">
<div class="container-full-width">
<?php
require_once('mysqli_connect.php');
$query =
"SELECT movie.* , ROUND(AVG(rate), 1) as rate
FROM movie_has_category, movie, rating
WHERE movie_has_category.categoryId = $categoryId
AND movie.movieId = movie_has_category.movieId
AND movie.movieId = rating.movieId
GROUP BY movie.movieId";
$response = @mysqli_query($dbc, $query);
if ($response) {
$resultsCount = mysqli_num_rows($response);
echo
'<h3 style="color: white">Showing ' . $resultsCount . ' results</h3>
<div class="wrapper">';
while($row = mysqli_fetch_array($response)) {
echo
'<div class="movie-category">
<div class="movie-info">
<div class="movie-details">
<h1>' . $row['name'] . '</h1>
<p>' . $row['summary'] . '</p>
<h3 class="stars">' . $row['rate'] . '/8</h3>
<button class="button secondary-btn" onclick='."'window.location.href=".'"movie.php?id='.$row['movieId'].'"'."'>See more</button>
</div>
</div>" .
'<a href="movie.php?id='.$row['movieId'].'"><img class="movie-cover" src="'.$row['cover_image_path'].'"></a>
</div>';
}
}
?>
</div>
</div>
</div>
<footer>
<p>
© 2019
<a href="https://www.linkedin.com/in/nikos-sklavounos">
Nikos Sklavounos.
</a>
All rights reserved.
</p>
</footer>
</body>
</html>