-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearchPrediction.php
More file actions
121 lines (111 loc) · 3.95 KB
/
searchPrediction.php
File metadata and controls
121 lines (111 loc) · 3.95 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
<?php
session_start();
include 'inc/dbConnection.php';
include 'php/source.php';
$dbConn = getDBConnection();
if(!isset($_SESSION["user"])) {
$_SESSION["name"] = "Guest";
}
if(isset($_POST['logout'])){
session_destroy();
header("Location: index.php");
}
if(isset($_POST['login'])){
goMain();
}
?>
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<head>
<title>Search Prediction</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<style>
input[type=text] {
width: 130px;
border: 2px solid #808080;
border-radius: 4px;
font-size: 16px;
background-color: white;
padding: 10px 15px 10px 25px;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<?php include 'inc/header.php';
include 'inc/nav.php';
?>
<div class= "wrapper">
<h4 id="welcome">Welcome </h4>
<div>
<iframe src="https://hw5-group4-chatapp.herokuapp.com/" class='myframe'></iframe>
</div>
<div style="float:left; width: 45%;">
<input type="text" id="myInput" onkeyup="tableSearch()" placeholder="Search..">
<br><br>
<table id="myTable" style="width:100%;" class="predictions">
<thead><tr>
<th>Movie Title</th>
<th>Prediction </th>
<th>UpVote</th>
</tr></thead>
<tbody>
<tr><?php predictionVote(); ?>
</tr>
</tbody>
</table>
</div>
</div>
<?php include 'inc/footer.php'; ?>
<script>
document.getElementById('welcome').innerHTML += '<?php echo $_SESSION["name"] ?>'
function tableSearch() {
let input = document.getElementById("myInput");
let filter = input.value;
let table = document.getElementById("myTable");
let tr = table.getElementsByTagName("tr");
let td;
for(let i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
if (td.innerHTML.indexOf(filter) > -1) {
tr[i].style.display = "";
}
else {
tr[i].style.display = "none";
}
}
}
}
</script>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- jQuery dependent!!! -->
<script>
function upVote(movieID){
$.ajax({
type: "GET",
url:"../php/upVote.php",
async: false,
dataType: "json",
data: { "movieID":movieID,
},
success: function( data, status ) {
if(!data)
alert("no data");
else
alert("success");
},
complete: function(data,status) { //optional, used for debugging purposes
}
});//AJAX
}
</script>
</body>
</html>