PHP and AJAXresponseXML instances AJAX can be used to return database information in XML.
AJAX Database to XML instance (Test Description: This instance function is not implemented)
In the following AJAX example, we will demonstrate how to read information from the MySQL database, convert the data to an XML document, and use this document in different places to display information.
This example is similar to the "php ajax Database" example in the previous section, but there is a big difference: In this example, we use the responseXML function to obtain XML data from the PHP page.
Receiving XML documents as responses gives us the ability to update multiple locations on the page, not just receiving and displaying a PHP output.
In this example, we use the information received from the database to update multiple elements.
In the drop-down list, Select a User: Peter Griffin in Lois Griffin in Joseph Swanson Glenn Quagmire.
This column consists of four elements:
MySQL database simple HTML form JavaScript PHP page
Database
The database used 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 |
HTML form
The preceding example contains a simple HTML form and a link to JavaScript: