-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
224 lines (210 loc) · 10.5 KB
/
results.php
File metadata and controls
224 lines (210 loc) · 10.5 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
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
<script type="text/javascript">
function search(term,id){
// prepare the request
var request = gapi.client.youtube.search.list({
part: "snippet",
type: "video",
q: term,
maxResults: 1
});
// execute the request
request.execute(function(response) {
var results = response.result;
$("#"+id).attr('src', "https://www.youtube.com/embed/"+results.items[0].id.videoId)
resetVideoHeight();
});
};
function resetVideoHeight() {
$(".video").css("height", $("#results").width() * 9/16);
}
</script>
<?php
require_once('Database.php');
// Create connection
$mysqli = new mysqli(Conf::DB_HOST, Conf::DB_USERNAME, Conf::DB_PASSWORD,Conf::DB_NAME);
mysqli_set_charset( $mysqli, 'utf8');
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: ");
} else {
//echo "Connection Successful\n";
}
?>
<div class="container">
<?php // Perform queries
$var = $_GET["var"];
$count = $_GET["count"];
$term = $_GET["term"];
$qmin = $_GET["qmin"];
if($var == "popular" || $var == "genre"){
if($var == "popular"){
$results = Database::query("CALL GetResults('". $var."',".$count.",NULL,NULL);");
} else {
$results = Database::query("CALL GetResults('".$var."',".$count.",'".$term."',NULL);");
echo "<h2 id=\"resultText\" style=\"width:100%;float:right\">Results for ".$term."</h2>";
}
while ($row = $results->fetch_assoc()) {
if($var == 'genre'){
echo "<div class=\"row\" style=\"margin-bottom:10px;background:white; float:right;width:100%\">";
} else {
echo "<div class=\"row\" style=\"margin-bottom:10px;background:white;width:100%\">";
}
echo "
<img src=\"".$row["RTPic"]."\" style=\"width:10%; float:left\"/>
<div style=\"float:left; width:60%; padding-left:15px;\">
<div style=\"float:left;width:100%\">
<h1 style=\"\">".$row["Title"]."</h1>
</br>
<h3 style=\"margin-top:0px; margin-right:10px; float:left\">Year:</h3>
<h3 style=\"margin-top:0px;color:orangered;font-weight:700\">".$row["Year"]."</h3>
<h3 style=\"margin-top:5px; margin-right:10px; float:left\">Audience Score:</h3>
<h1 style=\"margin-top:0px;color:orangered;font-weight:700\">".$row["Audience Score"]."</h1>
</div>
</div>
<img src=\"".$row["IMDBPic"]."\" style=\"width:10%; float:right\"/>
</div>";
}
}else{
if($qmin == ""){
$qmin = "NULL";
}
$results = Database::query("CALL GetResults('".$var."',".$count.",'".$term."',".$qmin.");");
if($var == "title" || $var=="director" || $var=="actor" || $var=="tag"){
echo "<h2>Results for ".$term."</h2>";
$video = 0;
while ($row = $results->fetch_assoc()) {
$video++;
echo "<div class=\"row\" style=\"margin-bottom:10px;background:white;width:100%\">";
echo"
<img src=\"".$row["RTPic"]."\" style=\"width:15%; float:left\"/>
<div style=\"float:left; width:60%; padding-left:15px;\">
<div style=\"float:left;width:100%\">
<h1 style=\"\">".$row["Title"]."</h1>
</br>
<h3 style=\"margin-top:0px; margin-right:10px; float:left\">Year:</h3>
<h3 style=\"margin-top:0px;color:orangered;font-weight:700\">".$row["Year"]."</h3>
<h3 style=\"margin-top:5px; margin-right:10px; float:left\">Audience Score:</h3>
<h1 style=\"margin-top:0px;color:orangered;font-weight:700\">".round($row["Audience Score"])."</h1>
";
if($var == "title"){
$tagResults = Database::query("CALL GetResults('tags',NULL,'".$row["Title"]."',NULL);");
if (!$tagResults) {
echo "No tags found";
}elseif($tagResults->num_rows == 0){
echo "No tags found";
} else {
echo "<h3 style=\"flaot:left\" \">Tags</h3>";
while ($tagRow = $tagResults->fetch_assoc()) {
echo $tagRow["tag"].", ";
}
}
echo"<script type=\"text/javascript\">
search('".$row["Title"]." ".$row["Year"]." Official Trailer','video".$video."');
</script>
<div style=\"background:black;width:100%\">
<iframe id=video".$video." width=\"420\" style=\"margin-left:20%;border:0px\" align=\"center\" height=\"315\" src=\"\">
</iframe>
</div>";
$recommendationResults = Database::query("CALL GetResults('recommended',NULL,'".$row["Title"]."',NULL);");
if (!$recommendationResults) {
echo "No Recommendations found";
}elseif($recommendationResults->num_rows == 0){
echo "No Recommendations found";
} else {
echo "<h3 style=\"flaot:left\" \">Recommendations</h3>";
while ($recRow = $recommendationResults->fetch_assoc()) {
echo "<a href=\"javascript:;\" onclick= \"searchTerm('".rtrim($recRow["title"])."')\"><img src=\"".$recRow["imdbPictureURL"]."\" style=\"width:20%; float:left\"/></a>";
}
}
}
echo"
</div>
</div>
<img src=\"".$row["IMDBPic"]."\" style=\"width:15%; float:right\"/>
</div>";
}
} else if($var == "directors"){
echo " <div style=\"padding:5px;\">
Minimum Movies: <input id=\"minMoviesD\" type=\"text\" value=\"".$qmin."\"/>
</div>";
while ($row = $results->fetch_assoc()) {
echo"
<div class=\"container\" style=\"margin-bottom:10px;background:white;width:100%\">
<div style=\"float:left;width:100%\">
<h2 style=\"\">".$row["DirectorName"]."</h2>
<h4 style=\"margin-top:5px; margin-right:10px; float:left\">Average Audience Score:</h4>
<h2 style=\"margin-top:0px;color:orangered;font-weight:700\">".round($row["Avg"])."</h2>
</div>
</div>";
}
} else if($var == "actors"){
echo" <div style=\"padding:5px;\">
Minimum Movies: <input id=\"minMoviesA\" type=\"text\" value=\"".$qmin."\"/>
</div>";
while ($row = $results->fetch_assoc()) {
echo "<div class=\"container\" style=\"margin-bottom:10px;background:white;width:100%\">
<div style=\"float:left;width:100%\">
<h2 style=\"\">".$row["ActorName"]."</h2>
<h4 style=\"margin-top:5px; margin-right:10px; float:left\">Average Audience Score:</h4>
<h2 style=\"margin-top:0px;color:orangered;font-weight:700\">".round($row["Avg"])."</h2>
</div>
</div>";
}
} else if($var == "timeline"){
$summaryResults = Database::query("CALL GetResults('summary',NULL,'".$term."',NULL);");
echo "
<script type=\"text/javascript\">
// Load the Visualization API and the corechart package.
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([";
if (!$summaryResults) {
echo "Error Connecting";
} else {
$array = "";
while ($summaryRow = $summaryResults->fetch_assoc()) {
$array= $array . "['".rtrim($summaryRow["genre"])."', ".$summaryRow["percent"]."],";
}
$array = trim($array, ",");
echo $array;
}
echo"
]);
// Set chart options
var options = {'title':'User Ratings By Genre',
'height':500};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>";
if($term == ""){
echo "<div id=\"chart_div\" style=\"display:none\"></div></br>";
} else {
echo "<div id=\"chart_div\" style=\"width:70%;margin-left:15%\"></div></br>";
}
Database::close();
Database::connect();
$detailResults = Database::query("CALL GetResults('details',NULL,".$term.",NULL);");
while ($row = $detailResults->fetch_assoc()) {
echo "<div class=\"container\" style=\"margin-bottom:10px;background:white;width:100%\">
<div style=\"float:left;width:100%\">
<h2 style=\"\">".$row["title"]."</h2>
<h4 style=\"float:right\">".$row["date"]."</h4>
<h4 style=\"margin-top:5px; margin-right:10px; float:left\">Rating Given:</h4>
<h2 style=\"margin-top:0px;color:orangered;font-weight:700\">".$row["rating"]."</h2>
</div>
</div>";
}
}
}
?>
</div>