Want To Be A Blogger  →  Start A Blog  →  Increase Traffic  →  Make Money Online  →  Recommended Things

Autocomplete Textbox Using jQuery,PHP And MySQL

Friday, Dec 15, 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.

Subscribe Our Newsletter And Get Tutorials And Offers Via Email

About Me

Hello, My Name is Mudit Jain. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of TalkersCode. I started this blog in february 2015 to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers.