Autocomplete Search Box / textbox in PHP MySQL

Today, We want to share with you autocomplete search box in php mysql.In this post we will show you global search in php mysql with examples, hear for autocomplete textbox with multiple values using jquery, php and mysql we will give you demo and example for implement.In this post, we will learn about How to create an suggestions search box in jQuery and PHP? with an example.

php autocomplete textbox from database example

There are the Following The simple About jquery autocomplete ajax json php Full Information With Example and source code.

As I will cover this Post with live Working example to develop php mysql ajax search autocomplete, so the autofill html form from database is used for this example is following below.

Step 1: Create a Database Connection File

    $dbname = "shops";
          die('Could not Connect MySql Server:' .mysql_error());

Step 2: Create an Autocomplete search form

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>suggestions Search Box in PHP MySQL -</title>
  <link rel="stylesheet" href="" />
  <script src=""></script>
  <script src=""></script>
  <!-- Bootstrap Css -->
  <link href="" rel="stylesheet">
<div class="container">
  <div class="row">
     <h2>Search Here</h2>
     <input type="text" name="search" id="search" placeholder="search here...." class="form-control">  
<script type="text/javascript">
  $(function() {
     $( "#search" ).autocomplete({
       source: 'ajax-db-search.php',

Step 3: Create a PHP Script for Search to DB

require_once "db.php";
if (isset($_GET['term'])) {
   $query = "SELECT * FROM products WHERE name LIKE '{$_GET['term']}%' LIMIT 25";
    $result = mysqli_query($conn, $query);
    if (mysqli_num_rows($result) > 0) {
     while ($product = mysqli_fetch_array($result)) {
      $results[] = $product['name'];
    } else {
      $results = array();
    //return json results
    echo json_encode($results);

how to implement an autocomplete search box or textbox in PHP MySQL with jQuery Ajax from the database table using jQuery UI Autocomplete JS.

I hope you get an idea about autocomplete search box in php mysql.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.