Hi everybody, this is my first blog ever. Today I am talking about auto suggestion using Ajax, jQuery and PHP. Lets start to build auto suggestion application

Step 1: Creating database table for auto suggestion application
CREATE TABLE IF NOT EXISTS autosuggession (
user_id int(11) NOT NULL AUTO_INCREMENT,
username varchar(50) NOT NULL,
PRIMARY KEY (user_id )
);

Now we insert some row in our table
INSERT INTO autosuggession (user_id, username) VALUES (NULL, ‘De Gea’), (NULL, ‘Rafael’), (NULL, ‘Shaw ‘), (NULL, ‘Jones’), (NULL, ‘Rojo’), (NULL, ‘Evans’), (NULL, ‘Di Maria’), (NULL, ‘Mata’), (NULL, ‘Falcao’), (NULL, ‘Rooney’), (NULL, ‘Januzaj’), (NULL, ‘Smalling’), (NULL, ‘Lindegaard’), (NULL, ‘Hernandez’), (NULL, ‘Carrick’), (NULL, ‘Herrera’), (NULL, ‘Henriquez’), (NULL, ‘Valencia’);

Step2: Creating view file index.php for auto suggestion(You can give any name)

Step 3: Create style.css

Step 4: Now create autosuggestion.js file

Step 5: Create search.php for ajax request

Demo
Download

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Auto suggestion using Ajax, jQuery and PHP
Tagged on:                         
  • Dil

    Hi
    Nice autocomplete workout.
    Question:
    How to restrict the minimum length of the query strings?
    I want to restrict to 3 characters long. Thanks
    Dil

  • papyc

    thanks bawa..