How to load data table with PHP code

This tutorial shows you how to use PHP code as Data source type in data table component. In our example we have page for products, and on first form of that page we will show data table of all products.

Datatable sql example

1. Login into developer panel.

2. Navigate to Pages menu item.

3. Select page pageProduct.

4. Drag and drop Data table component from all components list to formDatatableProduct. 

Data table component with php

5. In component properties section, select PHP code as Data source type. Click on textarea under Data source PHP label and enter PHP code. Variable result is an instance of AjaxProxy class. This variable is already instantiated. Attribute data of result variable ($result->data) must be an array with data array key. Array keys will be columns names of generated data table. Click on Save button.

PHP code for data table

6. Click on Save changes, go into your application and check out the results.