Autocomplete textbox with PHP, jQuery and MySql

Autocomplete textbox with PHP, jQuery and MySql

Autocomplete textbox

Autocomplete textbox is exceptionally easy to use for the web extend. In this instructional exercise, you can figure out how to actualize google like inquiry textbox in PHP. Utilizing jQuery UI we can without much of a stretch show auto proposal from the database under the textbox.

How about we begin the autocomplete textbox instructional exercise. Here we will show a textbox for aptitude passage. Once the client beginning to enter expertise, the autosuggestion abilities would be recorded under the textbox. These autosuggestion attitudes would be brought from the database abilities table.

Live Demo   Download Source Code


<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css.css">
<link rel="stylesheet" href="">
<link rel="stylesheet" href=" Sans">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="//">
  <script src="//"></script>
  <script src="//"></script>    
h1,h2,h3,h4,h5,h6 {font-family: "Oswald"}
body {font-family: "Open Sans"}
  $(function() {
    $( "#skills" ).autocomplete({
      source: 'search.php'
<body class="w3-light-grey">

<!-- Navigation bar with social media icons -->
<div class="w3-bar w3-black w3-hide-small">
  <a href="" class="w3-bar-item w3-button"><i class="fa fa-facebook-official"></i></a>
  <a href="" class="w3-bar-item w3-button"><i class="fa fa-twitter"></i></a>
  <a href="" class="w3-bar-item w3-button"><i class="fa fa-youtube"></i></a>
  <a href="" class="w3-bar-item w3-button"><i class="fa fa-google"></i></a>
  <a href="" class="w3-bar-item w3-button"><i class="fa fa-linkedin"></i></a>
<!-- w3-content defines a container for fixed size centered content, 
and is wrapped around the whole page content, except for the footer in this example -->
<div class="w3-content" style="max-width:1600px">

  <!-- Header -->
  <header class="w3-container w3-center w3-padding-48 w3-white">
    <h1 class="w3-xxxlarge"><a href=""><img src="img/logo.jpg" alt="Girl Hat" style="width:20%" class="w3-padding-16"></a></h1>
    <h6>Welcome to our <span class="w3-tag">Tutorial</span></h6>
  <!-- Image header -->

  <!-- Grid -->
  <div class="w3-row w3-padding w3-border">

    <!-- Blog entries -->
    <div class="w3-col l12 s12">
      <!-- Blog entry -->
      <div class="w3-container w3-white w3-margin w3-padding-large">
          <h2 style="text-align: center";>Autocomplete textbox using jQuery, PHP and MySQL by Lisenme</h2>
          <div class="ui-widget" style="text-align: center";>
             <label for="skills">Skills: </label>
           <input id="skills">





$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'demonstration_lisenme';
//connect with the database
$db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
//get search term
$searchTerm = $_GET['term'];
//get matched data from skills table
$query = $db->query("SELECT * FROM skills WHERE skill LIKE '%".$searchTerm."%' ORDER BY skill ASC");
while ($row = $query->fetch_assoc()) {
    $data[] = $row['skill'];
//return json data
echo json_encode($data);


You May Also Like

About the Author: Ranjith Kumar A

0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
3 years ago

Thanks you so much

3 years ago

thanks, this is what i was looking for.

3 years ago

how to add different columns from database into data variable

victorio bormolini
victorio bormolini
2 years ago

Hi, how do I do to consider the text typed as a new item to be posted in the database when the result of the search wasn’t a success?

1 year ago

how to retrieve data of autocomplete textbox on enter key press

Would love your thoughts, please comment.x