Home > Article > Backend Development > AJAX for PHP simple table data query example_PHP tutorial
Function introduction: AJAX WebShop 3 has supported PHP development since Beta2. AJAX WebShop integrates the development environment of PHP5, so there is no need to install and configure PHP additionally. This example will implement a simple data query operation of AJAX for PHP. This example is a single Table operations can also implement data query of master-slave tables.
1. Data table description
The example uses the Access database. Of course, you can also use mysql or other types of databases. The database name is: demo.mdb, and the table name is product. The created fields are PRODUCT_ID, PRODUCT_NAME, PRODUCT_PRICE, and PRODUCT_AREA.
2. Implement data query
First start AJAX WebShop 3, select "New Project" in File to create a new project.
Figure 1
Set the projectname and web server in the pop-up New Project dialog box. In this example, set the projectname to: php_example and set the web server to: PHP. If you want to modify the project path, please set the path to be stored in Directory.
Figure 2
After setting up the New Project, open "File" and select "New .PHP Service". In the pop-up dialog box, enter the subdirectory demo and set the "Class Name" to: simple_query ; After selecting "Query Data" in ServiceType and clicking "OK", the wizard will generate the PHP single-table query code according to the default template.
Figure 3
Enter the following database connection and sql code (the demo.mdb file is placed in the current code directory): $c.realpath($_SERVER['PATH_TRANSLATED'])."demo.mdb" ;
$sql = "select * from product";
$sqlcount = "select count(*) from product";
Analyzing the testquery.php code, the main implementation is as follows:
1. Loop the data structure and use addField to fill the fields (columns) to $xmlRequest: //fill metadata fields
>