<script type="text/javascript" src="js/jquery.js"></script>
<script type='text/javascript' src='js/jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript"> //----auto complete emp no--// $().ready(function() { $("#search_data").autocomplete("get_emp_info.php", { width: 237, minLength: 3,//search after three characters matchContains: true, mustMatch: true, selectFirst: false }); }); </script>
<table>
<tr>
<td style="border: none;color:#80600a;font-weight:bold;">Search:</td>
<td><input type="text" name="search_data" id="search_data" value="" size="35" autofocus></td>
</tr>
</table>
<?php
ob_start();
include('includes/connection.php');
$q = strtolower($_GET["q"]);
if ($q == '') {
header("HTTP/1.0 404 Not Found", true, 404);
}
//else (!$q) return;
else{
$sql = "SELECT pe.employee_no, pe.employee_name, pe.passport_no,
gov.res_id
FROM tbl_personal_info AS pe JOIN tbl_public_info AS pu ON (pe.employee_no = pu.employee_no) JOIN tbl_e_government_info AS gov ON (pu.employee_no = gov.employee_no)
WHERE pe.employee_no LIKE '%".$q."%' OR pe.employee_name LIKE '%".$q."%' OR pe.passport_no LIKE '%".$q."%' OR gov.res_id LIKE '%".$q."%'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$pid = $row["employee_no"];
$employee_name = $row["employee_name"];
$passport_no = $row["passport_no"];
$res_id = $row["res_id"];
echo "$employee_name|$pid|$passport_no|$res_id\n";
}
} else {
echo "0 results";
}
$conn->close();
}
?>