-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchint.php
More file actions
38 lines (29 loc) · 775 Bytes
/
Copy pathchint.php
File metadata and controls
38 lines (29 loc) · 775 Bytes
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
<?php
$connection = new mysqli("localhost","root","","eligibility"); //communication with database
$q = "select email from slogin";
$result = $connection->query($q);
$a=array();
$q = $_REQUEST["q"];
$hint = "";
while($r = $result->fetch_assoc()) //display table
{
$a[]=$r["email"];
}
echo $r;
// lookup all hints from array if $q is different from ""
if ($q !== "") {
$q = strtolower($q);
$len=strlen($q);
foreach($a as $name) {
if (stristr($q, substr($name, 0, $len))) {
if ($hint === "") {
$hint = $name;
} else {
$hint .= ", $name";
}
}
}
}
// Output "no suggestion" if no hint was found or output correct values
echo $hint === "" ? "no suggestion" : $hint;
?>