FreeKB - PHP Create an AJAX search engine
PHP - Create an AJAX search engine

On the page which has the search engine, ensure onkeyup="autocomplet()" is in the input form.

    <input type="text" is="search_id" onkeyup="autocomplet()">

This is the JavaScript.

function autocomplet() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#search_id').val();
	if (keyword.length >= min_length) {
			url: 'ajax_search_processing.php',
			type: 'POST',
			data: {keyword:keyword},
	} else {

function set_item(item) {
	// change input value
	// hide proposition list

This is the SQL stuff.

$con = new mysqli('ip_domain','username','password','database');
$keyword = $POST['keyword'];
$sql = "select * from tablename where name like '%$keyword%' ";
$sql_query = mysqli_query($con,$sql);

while ($row = mysqli_fetch_array($sql_query)) {
echo $row['data'];
<div id="search_results"></div>


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter e15fb in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |