===================
list.php
===================
<script>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<form name="f11" method="post">
<div>
<span style="color:#FFF">Enter * All Data Show</span> <input type="text" onchange="showUser(this.value)"/></div>
<div id="txtHint"><b>Person info will be listed here...</b></div>
</form>
</body>
</html>
================
getuser.php
==============
<?php
include('connection.php');
$q =$_GET['q'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if($q=='*')
{
$sql="select * from employee ";
}
else
{
$sql="SELECT * FROM employee WHERE emp_name OR emaill OR emp_username LIKE '%$q%'
AND emp_name OR emaill OR emp_username LIKE '%$q%'";
}
$result = mysqli_query($dd,$sql);
$n=mysqli_num_rows($result);
if($n > 0)
{
echo "<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['emp_name'] . "</td>";
echo "<td>" . $row['emaill'] . "</td>";
echo "<td>" . $row['emp_username'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else { echo "Data Not Found"; }
?>
</body>
</html>
list.php
===================
<script>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<form name="f11" method="post">
<div>
<span style="color:#FFF">Enter * All Data Show</span> <input type="text" onchange="showUser(this.value)"/></div>
<div id="txtHint"><b>Person info will be listed here...</b></div>
</form>
</body>
</html>
================
getuser.php
==============
<?php
include('connection.php');
$q =$_GET['q'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if($q=='*')
{
$sql="select * from employee ";
}
else
{
$sql="SELECT * FROM employee WHERE emp_name OR emaill OR emp_username LIKE '%$q%'
AND emp_name OR emaill OR emp_username LIKE '%$q%'";
}
$result = mysqli_query($dd,$sql);
$n=mysqli_num_rows($result);
if($n > 0)
{
echo "<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['emp_name'] . "</td>";
echo "<td>" . $row['emaill'] . "</td>";
echo "<td>" . $row['emp_username'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else { echo "Data Not Found"; }
?>
</body>
</html>
No comments:
Post a Comment