-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
105 lines (85 loc) · 3.04 KB
/
index.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "guide";
$link = mysqli_connect($servername, $username, $password, $dbname);
if ($link === false) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Encode+Sans" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="nav-bar">
<div class="logo">
<img src="images/logo.png" width="auto" height="70px">
</div>
<div style="display:none" class="name"> Guide Me </div>
</div>
<div class="container">
<center>
<form action="search-page.php" method="post" name="f" enctype="multipart/form-data">
<div class="search-bar input-group">
<input id="auto" list="area-list" name="city" type="text" class="search-input form-control" placeholder="Search City..." autocomplete="off">
<datalist id="area-list"></datalist>
<span class="search-btn-holder input-group-btn">
<button name="submit" type="submit" class="btn btn-primary btn-secondary search-btn " type="button">Search</button>
</span>
</div>
</form>
<div class="select-type">
<form id="guide-search" action="facesearch.php" method="post" name="f" enctype="multipart/form-data">
<button type="button" id="face-search" class="select-btn btn btn-primary">Face Search</button>
<input type="file" id="file-upload" name="file-upload" hidden/>
<input type="submit" id="submit-btn" hidden/>
</form>
</div>
</center>
</div>
<?php
$sql = "SELECT DISTINCT city FROM guide";
$result = mysqli_query($link, $sql);
$Areas = array();
?>
<script>
function sortByKey(array, key, dataList){
array.sort();
var length = array.length;
var keyLength = key.length;
var options = "";
for(var i=0; i<length; i++)
{
if(key === array[i].substring(0, keyLength)){
options += "<option value=" + array[i] + ">";
}
}
dataList.innerHTML = options;
}
var arr = [];
<?php
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo 'arr.push("'.$row["city"].'");';
}
}
?>
var auto = document.getElementById("auto");
var dataList = document.getElementById("area-list");
auto.oninput = function(){
var text = auto.value;
text = text.charAt(0).toUpperCase() + (text.slice(1)).toLowerCase();
sortByKey( arr, text, dataList);
};
</script>
<script src="upload.js"></script>
</body>
</html>
<?php
mysqli_close($link);
?>