PHP Ajax Example with Database

By t.wheeler on Oct 10, 2014 - 09:27am

This example demonstrates how to use AJAX (jQuery flavor) with PHP.  We take a simple database "fakecompany" with a single table "people".  People have names and phone numbers.  The SQL export for this database is included in the .zip file (below). 

The HTML initially uses AJAX to load in all the people and their phone numbers, using jquery.load(). 

Two forms are provided - one sends POST data via jquery.load to the PHP script, which adds people to the database, and then returns the latest person back to the initial page element.  The other form allows for dynamic first-name searches as you type (on Keypress). 

Download code files below.  Here's a screenshot:

ajax project screenshot