I have a page with from, and I maked an input, and when the user is writing, it's automaticlly will show the result from the DB(LIKE SEARCH). I used jquery. It's working but it's runing very slow. Can antbody help me?
The code is:
<html>
<head>
<title></title>
<link rel='stylesheet' type='text/css' href='new_style.css' />
<script src="jquery.js"></script>
<script type='text/javascript'>
setInterval(function() {
$('.input').keyup(function(){
var a = $('.input').val();
$.post('select.php?id=28',{"name":a}, function(data){
$('#msg').html(data);
});
});
},1000);
</script>
</head>
<body>
<?php
if(isset($_GET['id'])){
if(isset($_POST['name'])){
$name = $_POST['name'];
if($_POST['name']==""){
echo "text";
} else {
$query = mysqli_query($user->getDB(),"SELECT * FROM bla WHERE name LIKE '%$name%'");
if(mysqli_num_rows($query)==0){
echo "text";
} else { ?>
<table id='tables'>
<tr>
<th>name</th>
<th>text</th>
<th>text</th>
<th>text</th>
</tr><?php
while($show =mysqli_fetch_assoc($query)){
echo $show['name'];
}
}
echo "</table>";
if(isset($_POST['check'])) {
foreach($_POST['ch'] as $selected) {
echo $selected . " <br />";
}
}
}
} else { ?>
<p id='msg'></p>
</body>
</html>
<?php
}
}
?>