Build an AJAX search bar

You may also like...

  • Batfan

    Very nice tut. Would prefer something more simple though (ie. storing the search terms in an XML file). Their just search terms so, I’m not sure they need the security or hassle of setting up a MySQL db.

  • Scott Madden

    Thanks for the wonderful article I have added a link to it in the Tutorials section on the sidebar of our site.

  • Andy Leon

    Hi all,

    It’s worth noting that this was part of a series and in an earlier part we had set up the Web server and PHP configuration. Back then, PHP had “magic_quotes_gpc” switched on by default. This escapes all incoming GET and POST variables to make them safe for database queries. This is no longer the case, so if your PHP config is not set up like this, you should use the mysql_real_escape_string() as part of Step 12.

    $Cities = mysql_query(‘select * from City where Name like “%’.mysql_real_escape_string($SearchInput).’%” order by Population desc limit 10’);


  • Kate

    Thanks, I will be adding this to my favorites.

    Atlanta Web Design

  • ling

    Where do you add the list of cities in the PHP file?

  • web design barnsley

    Nice tut, cheers I may use that in a up coming project

  • Pingback: Building an Ajax Search Bar | Andy Leon()

  • Lucas Welander

    Hi, do you have any link or something similar but for ASP.NET? Ty for a nice article but if it were in it would be superb ;)

  • Free Watch Online Movies

    Thanks it’s great.i will use this script on my site.

  • IBU

    In the beginning of this tutorial it says “we’re going to be using the MySQL World Database, a sample database provided by MySQL that contains information on cities and countries”. I don’t see none of these files in your tutorials or the maybe clarification that we need to create these file by ourselves.

  • Vuxenleksaker

    Great tutorial! I will use it in one of my future projects.

  • ash

    in this how should i include ajax (the page should not refresh and the data should come directly when we enter)

    help textbox

    //Make a MYSQL connection
    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("Help") or die(mysql_error());
    //get all the data from unleashpm_overview table
    $name = $_POST['name'];
    $result = mysql_query("SELECT * FROM ajax_unleashpm_overview WHERE Question LIKE '%$name%'");
    //keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    // Print out the contents of each row
    echo $row['Question'];
    echo '’;
    echo $row['answer'];
    echo ”;

  • Pingback: Build an AJAX search bar | Web Designer – Defining the internet through beautiful design » Web Design()

  • Pingback: Create a search bar for your website « Adobe Help()

  • Peter

    Great Tutorial!
    I would like to use some of this code on my page. When I type in the search box, the results are shown, and when I click on a result, the page refreshes and the search box has the default text.

    I want to be able to select one result and have it displayed in the search box. How do I do that? And without the page refreshing.

  • mold removal in grants pass

    Hello mates, fastidious paragraph and nice arguments commented at this place, I
    am actually enjoying by these.

  • http://%URL% the text the romance back review

    Great article! We will be linking to this great article on our site.

    Keep up the good writing.

  • http://%URL% SMTP2GO Review

    Hi there friends, how is everything, and what you desire to say about this paragraph, in my view its
    actually remarkable in favor of me.


    I have read so many articles or reviews on the topic of the blogger lovers but
    this piece of writing is in fact a pleasant paragraph, keep it up.


    with brand new releases! Wow! Sound Terrific!Step 1 — Find a person’s Indiana Jones as well as Kingdom of your Crystal Mind Movie first you’ll be able to
    Search quite a few titles since you want, there tend to be no restricts.
    Browse many files in your favorite movie channels,
    television exhibits, sporting events plus more. Once
    you decide on what you are looking proceed to another location
    step.Step only two – Save Indiana Jones
    plus the Kingdom of this Crystal Cranium Movie, next Click on the file you only found to start your acquire.
    You will download Indy Jones and also the Kingdom in the Crystal Mind Movie
    and many other poker guides immediately. Your once membership fee will provide you
    with FREE DIGITAL VIDEO DISC Copy Computer software, Movie Competitors, CD Using up Software, VIP
    tech support team and further!Step 3 : Burn Indianapolis
    Jones and also the Kingdom of this Crystal Cranium Movie that will DVD.
    Play a newly saved movie using your pc, Home Live theatre, or Hdtv.
    The services provide you with the software necessary to easily shed your DISC Videos
    to help CD or perhaps DVD. Build the DVD motion picture collection.
    Join now and discover all you need to give to millions for user around the globe!
    Wow, isnt wonderful which you can watch it all the time, Yes!

    So will not wait now and find Ready to watch out and In Jones and also Kingdom in the Crystal Brain Movie Nowadays!

    Indispensable Lcd television AccessoriesLuce mannequin TV pores and skin look stand
    solely model and keep in various areas of a family
    home, plane as well as yacht. It can be an ultra small television with high quality
    PC. This standalone TV isn’t going to require another components. The a few parallel watching sources that Luce style offers usually are HDTV keep an eye on and hd monitor. The extensive aspect monitor format utilized for the product is highly worthy of DTV, DVD in addition to HDTV resource material.You will be able to view this kind of model inside bright light along with in almost any angle with the comfort of one’s room.

    This is realistic a result of wide experiencing angle
    and also high lumination level enjoyed by your monitor.
    The living quarters of your abode or office is usually augmented and living area can end up increased using
    the fence mounts. Wall supports of plasma tv set of LCD video are suitable with the aim.
    The benefits of using these units are a good number of.

    The unit will be wall attached with the various models of walls
    car without any flat solar panel. Gold plated attaches are utilized specially to
    get superior alert. 99. 95 p’cent oxygen absolutely free copper is required in the gps watch. The 1 metre greyish scat incorporated while in the unit provides you with affordable.Wall brackets are you can buy to meet on all sorts of wall space. They may carry some weight with 30 kgs. LCD home appliances are televisions, at days are given the small-scale tilt mount that is suitable intended for flat section televisions. The compact tilt offered on the market usually satisfies thirteen within . to twenty-four inch telly displays. Projector wall mounts too tend to be obtainable in the LCD home appliances are televisions.Mounts can be acquired for tv mount, wall support, screen support, desk position and threshold mount. Real hardwood veneer through safety goblet shelves tend to be attractive and provide a sensible look. Besides providing ample increasing space moreover it acts because storage designed for DVD’s,
    controllers along with other accessories with regard to gaming.
    They possess soft finishing doors. Enough fresh air is provided to make sure efficient
    operating from the device. Cable administration
    provided in your unit helps prevent clutter and keep your wires planned.
    The system features a good performance thanks to high top quality
    leads utilized for it. You will get high superior cables designed for speakers.
    It will let you enjoy a complete potential belonging to the device such as best
    smart quality not to mention vision. Decorative cable-trunking features are specially provided to cover speaker connections.
    A disguise of covered aluminium has the display cleaner.

    The clearer removes acne bacteria. However, it just isn’t advised to work with it upon flat screens because the alcohol together with sponge could harm the actual screen. The brand new innovation from the technology can be LC TV FOR PC phone, which are made for business individuals.They consist of two fast access to the internet, 2 SIM charge cards, touch computer screen, two video cameras, sliding display, micro SD position, memory minute card, GPRS, GSM, FAX, many wide variety of computer secrets, blue the teeth, television recorder, Email, television routine, movie participant and a variety of others.In house Antenna- Assistive Touch For Auto Tv AntennaI am certain that your hunt for indoor antenna has reach an end when you read this information. Yes, gone are days gone by when we must search forever for {backyard|interior|inside|indoors

  • ilex

    Tips on how to Select Ideal Projector

  • casinoeuro

    Have more From home Media With your Great Electronic devices!

  • liposuction dominican republic

    Every weekend i used to visit this web site, because i want enjoyment,
    for the reason that this this site conations really nice funny stuff too.

    Visit my wesbite at liposuction dominican republic