Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Autocomplete Textbox Using jQuery,PHP And MySQL

Tuesday, Mar 7, 2017

Tags:- jQuery PHP MySQL

In this tutorial we will show you how to create autocomplete textbox using jQuery, PHP and MySQL.When user enter some letter a box with some related words will display and you can select the word from that box.This is all done with the help of jQuery UI you have to download it to create autocomplete textbox.You may also like disable auto complete form using jQuery.

See Demo
Autocomplete Textbox Using jQuery, PHP And MySQL

To Create Autocomplete Textbox It Takes Only Two Steps:-

  1. Make a HTML file and define markup and scripting
  2. Make a PHP file to send related word suggestion

Step 1.Make a HTML file and define markup and scripting

We make a HTML file and save it with a name textbox.html

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<link rel="stylesheet" href="jquery-ui.css">
<script type="text/javascript">
 $( "#coding_language" ).autocomplete({
  source: 'autocomplete.php'
<div id="wrapper">

<div class="ui-widget">
 <p>Enter Coding Language</p>
 <input type="text" id="coding_language">


In this step we first insert all the files required for the working of autocomplete textbox and then create a textbox to enter text and jQuery autocomplete function to show related words for that text.In autocomplete() function there is parameter 'source' it takes page address from where you will get word suggestions ubder this function we use 'autocomplete.php' file which we were going to create in next step.You may also like dynamic textbox using Javascript.

Step 2.Make a PHP file to send related word suggestion

We make a PHP file and save it with a name autocomplete.php

// Database Structure 
CREATE TABLE `coding_language` (
 `name` text NOT NULL,



$searchTerm = $_GET['term'];

$select =mysql_query("SELECT * FROM coding_language WHERE name LIKE '%".$searchTerm."%'");
while ($row=mysql_fetch_array($select)) 
 $data[] = $row['name'];
//return json data
echo json_encode($data);

In this step we create a sample table called 'coding_language' and insert some web programming languages and then get the term from 'textbox.html' page and then find and send the related languages.You can view our form validation using jQuery to filter data before querying the database.

Thats all, this is how to create autocomplete textbox using jQuery, PHP and MySQL.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH