Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL
This tutorial shows how to create simple and attractive Ajax based search using PHP, jQuery, MySQL and Ajax.
Table Structure:
1 2 3 4 5 6 | CREATE TABLE `search` ( `id` int(11) NOT NULL auto_increment, `text` varchar(255) NOT NULL, `link` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) |
Javascript Code:
1 2 3 4 5 6 7 8 | $(".searchBtn").click(function(){ //show the loading bar showLoader(); $('#sub_cont').fadeIn(1500); $("#content #sub_cont").load("search.php?val=" + $("#search").val(), hideLoader()); }); |
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <div class="textBox"> <input type="text" value="" maxlength="100" name="searchBox" id="search"> <div class="searchBtn"> </div> </div> <br clear="all" /> <div id="content"> <div class="search-background"> <label><img src="loader.gif" alt="" /></label> </div> <div id="sub_cont"> </div> </div> |
PHP Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | include("dbcon.php"); $rec = $_REQUEST['val']; //get table contents if($_REQUEST['val']) { $sql = "select * from search where text like '%$rec%'"; } else { $sql = "select * from search "; } $rsd = mysql_query($sql); $total = mysql_num_rows($rsd); |
Related Posts :
8 to “Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL”
Post comment
Who Am I

Zeeshan Rasool
Software Engineer - PHP
Lahore - Pakistan
Skype: zeeshan-rasool
gTalk: zishan.rasool85
Categories
- AJAX (24)
- Codeigniter (16)
- CSS (7)
- Facebook (8)
- Joomla (1)
- JQuery (34)
- Miscellaneous (3)
- Mootools (1)
- MySQL (4)
- PHP (43)
- SEO (2)
- Technology (6)
- Twitter (1)
- Web Development (58)
Archives
- August 2010 (7)
- July 2010 (9)
- June 2010 (9)
- May 2010 (8)
- April 2010 (17)
- March 2010 (13)
- February 2010 (3)
Tags
99points
adobe
AJAX
ajax pagination
ajax rating
ajax tutorial
captcha
Codeigniter
codeigniter 2.0
codeigniter recaptcha
CSS
css tutorials
curl
dreamweaver cs5
Facebook
Facebook. PHP. JQuery
facebox
farmville
ffmpeg
flv
google api
hacking
image gallery
Joomla
JQuery
jQuery Sliding
Jquery tutorial
mafia war
Mootools
MySQL
Payment
PHP
php curl
Poll System
recaptcha
RSS Feed
SEO
simplepie
socail networking
ssl
Tutorials
Twitter
Web
XSS
youtube
Comments
- Super Ajax Polling/Voting System using JQuery, Ajax, PHP and MySQL | Bodeezy Bux on Ajax Rating System: Create Simple Ajax Rating System using jQuery AJAX and PHP.
- Adam on Create Animated Tabs using JQuery and CSS.
- ZeeShaN on Reloaded: Facebook Style Wall Posting and Comments System using jQuery PHP and Ajax.
- Marco on Reloaded: Facebook Style Wall Posting and Comments System using jQuery PHP and Ajax.
- Facebook Style Wall Posting and Comments System using jQuery PHP and Ajax | Programmer Heaven on Facebook Style TextArea with Wall Posting Script using jQuery PHP and Ajax.
ZeeShaN






[...] This post was mentioned on Twitter by Pablo Lara H, 99_Points. 99_Points said: Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL http://dlvr.it/1TgG7 [...]
Not sure if this already happens as using iPhone and it doesn’t on here – however how would you get it to display results whilst typing so no need to click search
know what I mean??
@mgpwr
[...] http://www.99points.info/2010/06/ajax-tutorial-how-to-create-ajax-search-using-php-jquery-and-mysql/ [...]
[...] Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL [...]
@mgpwr
hmmm, You can do this by just replacing the click event of button to keypress or key up event of input box.
$("#search").keypress(function()[...] Ajax Tutorial: How to Create Ajax Search Using PHP jQuery and MYSQL [...]
[...] 3.How to Create Ajax Search Using PHP jQuery and MYSQL This tutorial shows how to create simple and attractive Ajax based search using PHP, jQuery, MySQL and Ajax. [...]
Good stuff!