DataTables is a jQuery library used to show the entire list of records in an HTML table. It combines some features like key search, pagination list, data sorting, filter and etc. In DataTables we can limit the number of records to be presented per page.

DataTables gives both client-side and server-side processing. In this post, we are going to utilize the database results by using DataTables server-side processing. A PHP file used to calls requested columns and returns array of results. This resultant array is encoded to the JSON format which will send the response to the DataTables AJAX script.

DataTable Defining Code

The following code uses to define HTML code for the DataTable. This code has needed CSS and JavaScript library includes a top of the page. The table HTML tag has an id attribute which is used to define and set the table as a DataTable.

and HTML Table details

DataTable Initialize using jQuery script

The following code shows the jQuery DataTable Initialize by setting the needed DataTable property key features. In this code, the serverSide property is set as true and the server side file path is specified for the ajax property key. These keys are used to set the server side processing for the DataTable.

Server-Side Processing script

The following PHP code is provided the dataset details as JSON format. It contains column name and respective values as an array.

 

Download   Demo

2 Replies to “Server-Side Processing DataTable with PHP”

Leave a Reply

Your email address will not be published. Required fields are marked *