index.php
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0"> <title></title> <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css"> <link rel="stylesheet" type="text/css" href="css/shCore.css"> <link rel="stylesheet" type="text/css" href="css/demo.css"> <style type="text/css" class="init"> th, td { white-space: nowrap; } div.dataTables_wrapper { width: 800px; margin: 0 auto; } </style> <script type="text/javascript" language="javascript" src="js/jquery.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js" charset="utf-8"></script> <script type="text/javascript" language="javascript" src="js/shCore.js"></script> <script type="text/javascript" language="javascript" src="js/demo.js"></script> <script type="text/javascript" language="javascript" class="init" charset="utf-8"> $(document).ready(function() { $('#datatables').dataTable( { "processing": true, "serverSide": true, "ajax": "js/server_processing.php" } ); } ); </script> </head> <body class="dt-example"> <div class="container"> <table id="datatables" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Name</th> <th>Date 1</th> <th>Date 2</th> <th>Place</th> <th>Book number</th> <th>Location</th> <th>Status</th> <th>Country</th> <th>Religion</th> <th>Card ID</th> <th>Description</th> <th>Data 1</th> <th>Data 2</th> </tr> </thead> </table> </div> </body> </html>
server-processing.php
<?php /* * DataTables example server-side processing script. * * Please note that this script is intentionally extremely simply to show how * server-side processing can be implemented, and probably shouldn't be used as * the basis for a large complex system. It is suitable for simple use cases as * for learning. * * See <a href="http://datatables.net/usage/server-side" target="_blank">http://datatables.net/usage/server-side</a> for full details on the server- * side processing requirements of DataTables. * * @license MIT - <a href="http://datatables.net/license_mit" target="_blank">http://datatables.net/license_mit</a> */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Easy set variables */ // DB table to use $table = 'datatables'; // Table's primary key $primaryKey = 'id'; // Array of database columns which should be read and sent back to DataTables. // The `db` parameter represents the column name in the database, while the `dt` // parameter represents the DataTables column identifier. In this case simple // indexes ); // SQL server connection information 'user' => 'root', 'pass' => 'psw', 'db' => 'datatables', 'host' => 'localhost' ); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * If you just want to use the basic configuration for DataTables with PHP * server-side, there is no need to edit below this line. */ require( 'ssp.class.php' ); echo json_encode( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ) );