-
Notifications
You must be signed in to change notification settings - Fork 10
/
search.php
37 lines (33 loc) · 964 Bytes
/
search.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
<?php
include_once "./login/connect.php";
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME)
OR die ('Could not connect to MySQL: '.mysql_error());
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$key=$_GET['key'];
$array = array();
$query="SELECT email FROM `users` where email LIKE '%{$key}%'";
$checkResult = mysqli_query($conn,$query);
while($row=mysqli_fetch_assoc($checkResult))
{
$array[] = $row['email'];
}
echo json_encode($array);
?>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script src="typeahead.min.js"></script>
</head>
<body>
<input type="text" name="typeahead">
<script>
$(document).ready(function(){
$('input.typeahead').typeahead({
name: 'typeahead',
local:'search.php?key=%QUERY',
limit : 10
});
});
</script>
</body>