-
Notifications
You must be signed in to change notification settings - Fork 0
/
moviedetails.php
255 lines (184 loc) · 8.26 KB
/
moviedetails.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
<?php
$page_title = "Movie Information";
$body_id = "content2";
require_once ('includes/database.php');
//retrieve movie id
$id = $_GET['id'];
//select statement
$query_str = "SELECT * FROM $tblMovies WHERE movie_id = '" . $id . "'";
$review_str = "SELECT review_heading, review_content, review_user_id, review_rating FROM $tblReviews WHERE reviews.review_movie_id=" . $id . "";
//execute the query
$result = $conn->query($query_str);
$review_result = $conn->query($review_str);
//Handle selection errors
if (!$result || !$review_result) {
$errno = $conn->errno;
$errmsg = $conn->error;
echo "Selection failed with: ($errno) $errmsg<br/>\n";
$conn->close();
exit;
} else { //display results in a table
//insert a row into the table for each row of data
$result_row = $result->fetch_assoc();
//$review_result_row = $review_result->fetch_assoc();
$page_title = "TMRS: " . $result_row['movie_name'];
require_once ('includes/header.php');
?>
<div class="container wrapper moviedetails">
<br>
<div class="row ">
<div class="col-sm-3 col-xs-offset-1">
<img class="img-responsive" width="210" height="315" src="<?php echo $result_row['movie_img']; ?>" alt=""/>
</div>
<div class="col-sm-8">
<div class="panel panel-default">
<div class="panel-body moviedetails">
<div class="row">
<div class="col-sm-4">
<h1><?php echo $result_row['movie_name'] ?></h1>
</div>
<div class="col-sm-8">
<div class="row">
<div class="col-sm-2">
<h3 style="font-size: 50px; color: limegreen;"> <?php echo $result_row['movie_rating'] ?> </h3>
</div>
<div class="col-sm-10">
<br>
<h4>/10</h4>
</div>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-4">
<h3>Genre: <?php echo $result_row['Genre'] ?></h3>
<h3>Runtime: <?php echo $result_row['Runtime'] ?></h3>
</div>
<div class="col-sm-8">
<h3>Director: <?php echo $result_row['Director'] ?></h3>
<h3>Year: <?php echo $result_row['movie_year'] ?></h3>
</div>
</div>
<p class="lead"><?php echo $result_row['movie_bio'] ?></p>
<?php if (empty($login)) { ?>
<p class="lead"><a href="loginpage.php">Sign in</a> or <a href="registration.php">register</a> to leave a review or make this a favorite movie!</p>
<?php } else { ?>
<p>
<a class="btn btn-info" href="addreview.php?id=<?php echo $result_row['movie_id'] ?>" role="button">ADD REVIEW <i class="fa fa-plus"></i></a></p>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="row review">
<div class="col-md-12 box-review2">
<?php for ($i = 0; $i < 5; $i++ ) :
while ( $review_result_row = $review_result->fetch_assoc() ) : ?>
<?php
//$user_str = "SELECT user_full_name FROM $tblUsers INNER JOIN reviews ON reviews.review_user_id= users.user_id";
$user_str = "SELECT user_full_name FROM $tblUsers INNER JOIN reviews ON users.user_id = ".$review_result_row['review_user_id']." ";
$user_result = $conn->query($user_str);
$user_result_row = $user_result->fetch_assoc()
?>
<div class="row">
<div class="col-sm-7">
<h3 class="<?php
if ($review_result_row['review_heading' > 4 ]){
echo 'text-success';
} elseif ( $review_result_row['review_heading'] < 2 ) {
echo 'text-danger';
}
?>"> <?php echo $review_result_row['review_heading'] ?></h3>
</div>
<div class="col-sm-1">
<p class="lead"> <?php echo $review_result_row['review_rating'] ?>/10</p>
</div>
<div class="col-sm-4">
<p class="lead">Reviewed by: <?php echo $user_result_row['user_full_name'] ?></p>
</div>
</div>
<div class="content">
<p class="lead"> <br/><?php echo $review_result_row['review_content'] ?></p>
</div>
<hr style="border-top: 3px solid black;">
<?php endwhile; endfor; ?>
</div>
</div>
<?php
//select statement
$query_str = "SELECT * FROM movies WHERE Genre = '" . $result_row['Genre'] . "'";
//execut the query
$result = $conn->query($query_str);
//Handle selection errors
if (!$result) {
$errno = $conn->errno;
$errmsg = $conn->error;
echo "Selection failed with: ($errno) $errmsg<br/>\n";
$conn->close();
exit;
} else { //display results in a table
?>
<div class="container wrapper">
<div class="row">
<div class="col-sm-12 text-center">
<h1>Recommended Movies</h1>
<br>
</div>
</div>
<div class="movie-list">
<?php
$i = 0;
$count = 0;
while ($result_row = $result->fetch_assoc()) :
$i++;
$count++;
if ($i == 1) :
?>
<div class="row">
<?php endif; ?>
<div class="col-sm-3 ">
<div class="thumbnail ">
<div class="caption movieBox" >
<div class="text-center movieBox">
<a href="moviedetails.php?id=<?php echo $result_row['movie_id'] ?>">
<img width="210" height="315" src="<?php echo $result_row['movie_img'] ?>"/>
</a>
</div>
<h3 style="font-family: Montserrat-Regular" class="text-center mvname">
<?php
echo $result_row['movie_name'] ;
?>
</h3>
</div>
</div>
</div>
<?php if($count == 20)
break;
?>
<?php if ($i == 4) : ?>
</div>
<br>
<?php $i = 0; endif; endwhile; ?>
</div>
</div>
<?php
// clean up result sets when we're done with them!
$result->close();
}
?>
<?php } ?>
</div>
<?php
// close the connection.
$conn->close();
?>
<footer class=" text-center foot1">
<div class="text-center container-fluid p-3" style="background-color: black;opacity: 0.5; color: white">
<h5 style="color: white">© 2021 Copyright: TMRS.com </h5>
</div>
<!-- Copyright -->
</footer>
<!-- Footer -->
</body>
</html>