PHPandAJAXMySQLDatabaseExample reference address: http://www.w3schools.com/PHP/php_ajax_database.asp
AJAX can be used for interactive communication with a database.
AJAX Database Example
In the AJAX example below we will demonstrate how a web page can fetch information from a MySQL database using AJAX technology.
Select a Name in the Box Below
Select a User: Peter Griffin in Lois Griffin in Joseph Swanson Glenn Quagmire
User info will be listed here.
This example consists of four elements:
A MySQL database a simple HTML form a JavaScript a PHP page
The Database
The database we will be using in this example looks like this:
Id FirstName LastName Age Hometown Job
| 1 |
Peter |
Griffin in |
41 |
Quahog |
Brewery |
| 2 |
Lois |
Griffin in |
40 |
Newport |
Piano Teacher |
| 3 |
Joseph |
Swanson |
39 |
Quahog |
Police Officer |
| 4 |
Glenn |
Quagmire |
41 |
Quahog |
Pilot |
The HTML Form
The example above contains a simple HTML form and a link to a JavaScript: