-
Notifications
You must be signed in to change notification settings - Fork 1
/
what_to_watch.php
195 lines (176 loc) · 6.61 KB
/
what_to_watch.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
<?php
session_start();
################### Check Login Status ###################
if(!$_SESSION["login"]){
header('Location: index.html');
}
else{
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<nav class="navbar navbar" style="color:black">
<div class="container-fluid">
<!--Home-Header button of navbar -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#topNavBar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="profile.php" style="color:white">NeXtflix</a>
</div>
<div class="collapse navbar-collapse" id="topNavBar">
<ul class="nav navbar-nav navbar-right">
<li class="">
<a href="logout.php" style="color:white">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Logout
</a>
</li>
</ul>
<ul class ="nav navbar-nav navbar-right">
<li class="">
<a href="verify.php" style="color:white">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit Profile
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right" style="color:white">
<li class="">
<a href="what_to_watch.php" style="color:white">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> What to Watch!
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right" style="color:white">
<li class="">
<a href="random.php" style="color:white">
<span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span> Surprise me!
</a>
</li>
</ul>
</div>
</div>
</nav>
<style>
body {
background-color: black;
background-repeat: no-repeat;
}
.navbar{
font-family: Avenir;
border-radius: 0;
}
h1{
font-family: Avenir;
color: white;
text-align: center;
}
h2 {
font-family: Avenir;
color: white;
margin-left: 1%;
}
h3 {
font-family: Avenir;
color: white;
margin-left: 2%;
}
p{
font-family: Avenir;
color: white;
margin-left: 5%;
}
input{
font-family: Avenir;
}
</style>
<body>
<h1>Welcome: <?php echo($_SESSION["username"]);
}?>
</h1>
<h2> What to watch: </h2>
<h3> Watch again: </h3>
<div style="overflow-x:auto;">
<table id="popularShows" border = "1" class="table-responsive" align = center>
<tr id="showRow">
</tr>
</table>
</div>
<h3> Or try something new: </h3>
<div style="overflow-x:auto;">
<table id="popularMovies" border = "1" class="table-responsive" align = center>
<tr id="movieRow">
</tr>
</table>
</div>
<h3> Based on actors you like: </h3>
<div style="overflow-x:auto;">
<table id="actors" border = "1" class="table-responsive" align = center>
<tr id="actorRow">
</tr>
</table>
</div>
<h2>
<?php
include_once("./library.php");
$con = new mysqli($SERVER, $USERNAME, $PASSWORD, $DATABASE);
if (mysqli_connect_errno()) {
echo("Can't connect to MySQL Server.");
return null;
}
$username = $_SESSION["username"];
$getGenre = "SELECT fav_genre FROM Users WHERE username = '$username'";
$fav_genre = mysqli_query($con, $getGenre);
while($genres = mysqli_fetch_array($fav_genre)) {
$genre = $genres['fav_genre'];
}
$findGenre = "SELECT Genre FROM TVShows WHERE TVID IN (SELECT TVID FROM starin_tv WHERE Actor_ID IN (SELECT Actor_ID FROM Fan_Of WHERE Username='$username'))";
$actorGenre = mysqli_query($con, $findGenre);
while($actorWatch = mysqli_fetch_array($actorGenre)) {
$toWatch = $actorWatch['Genre'];
}?></h2>
<script type = "text/javascript">
//Populate seen before table
var tvrow = document.getElementById("showRow");
var i = 0;
<?php
$query1="(SELECT Title, TVID AS ID from TVShows WHERE TVID IN (SELECT TVID from Watched_show Where Username = '$username')) UNION ALL (SELECT Title, movie_id AS ID from Movies WHERE movie_id IN (SELECT movie_id from Watched_movie Where Username = '$username'))";
$result = mysqli_query($con, $query1);
while($tvrow = mysqli_fetch_array($result)) { ?>
var x = tvrow.insertCell(i);
<?php $title = $tvrow['ID']; ?>
x.innerHTML ="<a href='info.php?id=<?php echo($title); ?>'><img src='./images/<?php echo($title); ?>.jpg' style='width:180px;height:152px;'></a>";
i++;
<?php } ?>;
//Populate haven't seen before table
var mrow = document.getElementById("movieRow");
var j = 0;
<?php
$query2="(SELECT Title,TVID AS ID from TVShows WHERE TVID NOT IN (SELECT TVID from Watched_show Where Username = '$username') AND Genre='$genre') UNION ALL (SELECT Title, movie_id AS ID from Movies WHERE movie_id NOT IN (SELECT movie_id from Watched_movie Where Username = '$username') AND Genre='$genre')";
$result2 = mysqli_query($con, $query2);
while($mrow = mysqli_fetch_array($result2)) { ?>
var x = mrow.insertCell(j);
<?php $title = $mrow['ID']; ?>
var link = "<a href='info.php?id=<?php echo($title); ?>'><img src='./images/<?php echo($title); ?>.jpg' style='width:180px;height:152px;'></a>";
x.innerHTML = link;
j++;
<?php } ?>;
// Populate actors table
var arow = document.getElementById("actorRow");
var k = 0;
<?php
$query3="SELECT TVID AS ID FROM TVShows WHERE Genre='$toWatch' UNION ALL (SELECT movie_id AS ID FROM Movies WHERE Genre='$toWatch')";
$result3 = mysqli_query($con, $query3);
while($arow = mysqli_fetch_array($result3)) { ?>
var x = arow.insertCell(k);
<?php $title = $arow['ID']; ?>
var link = "<a href='info.php?id=<?php echo($title); ?>'><img src='./images/<?php echo($title); ?>.jpg' style='width:180px;height:152px;'></a>";
x.innerHTML = link;
k++;
<?php } ?>;
</script>
</body>
</html>