-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsearch_function.php
More file actions
58 lines (51 loc) · 1.86 KB
/
search_function.php
File metadata and controls
58 lines (51 loc) · 1.86 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
//RUNS ON SERENA'S LOCAL DATABASE UNTIL AWS SET UP
<?php
//if($_GET['q'] == 'Search...'){
//header('Location: search_function.php');
//}
if($_GET['q'] !== ''){
$con = mysql_connect('localhost','root','TestCOV345');
$db = mysql_select_db('cov_sample_data')
?>
<head>
<head></head>
<script type="text/javascript">
function active(){
var searchBar = document.getElementById('searchBar');
if(searchBar.value == 'Search...'){
searchBar.value == ''
searchBar.placeholder = 'Search...'
}
}
</script>
</head>
<body>
<form action="search_function.php" method="GET" id="searchForm" />
<input type="text" id="searchBar" placeholder="" value="Search..." maxlength="25" autocomplete="off" onMouseDown="active();" onBlur="" />
<input type="submit" name="submit" id="searchBtn" value="Go!" />
</form>
<?php
if(!isset($_POST['submit'])){
echo '';
} else {
$query = mysql_query("SELECT * FROM trips WHERE tripID LIKE '%$q%' OR startTime LIKE '%$q' ");
$num_row = mysql_num_rows($query);
while ($row = mysql_fetch_array($query)){
$tripID = $row['tripID'];
$segmentID = $row['segmentID'];
$userID = $row['userID'];
$startTime = $row['startTime'];
$endTime = $row['endTime'];
$dataPoints = $row['dataPoints'];
$flags = $row['flags'];
echo '<h3>' . $tripID . '</h3><p>' . startTime '</p><br />';
}
}
?>
</body>
</html>
<?php
} else {
header('Location: search_function.php')
}
?>