How To Create Ajax Search Using PHP Jquery and Mysql

ajax search

Ajax Search. I love ajax very much. I have expressed my feeling by writing tutorial about ajax here, here, here and here. This tutorial shows how to create ajax search form using PHP, Jquery and Mysql. When you click the search button or press enter key the results will be displayed on the same page and without refresh page process. This is very interesting and simple. Take a look at beautiful live demo.

Live Demo

Here we use database of wordpress, wp_posts table is used.

HTML Page Ajax Search

We create an input text and button to facilitate users to search tutorials. Also we create a list to display the search results.

JavaScript

We specify so that when users click button or press enter key the process of searching data begins. Here we use click and keyup event. As usual we use ajax function to perform data change in the background.
To limit when users input nothing but click the button or press enter, we create simple checking using if.

PHP Code

Database configuration file used in this tutorial. Adjust the server location, username, password and database name
file : db.php

This is the code that searchs articles based on the user input and brings the results in ajax search way.Once again we performs checking using if to ensure when no data found it will give an output “No Tutorial Found”
file : search.php

Css

Live Demo
Facebook Comments
 

Agung Setiawan

Agung Setiawan adalah software engineer di BukaLapak.com, penulis sekaligus pecinta sastra, dan pembaca buku

 
Halo, perkenalkan saya Agung Setiawan.
Saya Software Engineer di BukaLapak.
Simak pemikian saya soal dunia Software Engineering via Twitter di @agungsetiawanmu dan facebook
Blog ini saya update seminggu sekali jadi sering-sering saja mampir
Mau belajar Vim bareng saya?
Belajar ngoding dari nol menggunakan PHP

3 thoughts on “How To Create Ajax Search Using PHP Jquery and Mysql

  1. For Kendall, a runner, the problem is her muscled calves; for Justine, it’s high arches that make it hard for her to get her foot into some boots.”We weren’t aware of how many fit issues there are,” says Kendall, who organized fit workshops with local women as part of her research.

  2. Pingback: Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *