post.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * DataTables example server-side processing script.
  4. *
  5. * Please note that this script is intentionally extremely simply to show how
  6. * server-side processing can be implemented, and probably shouldn't be used as
  7. * the basis for a large complex system. It is suitable for simple use cases as
  8. * for learning.
  9. *
  10. * See http://datatables.net/usage/server-side for full details on the server-
  11. * side processing requirements of DataTables.
  12. *
  13. * @license MIT - http://datatables.net/license_mit
  14. */
  15. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  16. * Easy set variables
  17. */
  18. // DB table to use
  19. $table = 'datatables_demo';
  20. // Table's primary key
  21. $primaryKey = 'id';
  22. // Array of database columns which should be read and sent back to DataTables.
  23. // The `db` parameter represents the column name in the database, while the `dt`
  24. // parameter represents the DataTables column identifier. In this case object
  25. // parameter names
  26. $columns = array(
  27. array( 'db' => 'first_name', 'dt' => 'first_name' ),
  28. array( 'db' => 'last_name', 'dt' => 'last_name' ),
  29. array( 'db' => 'position', 'dt' => 'position' ),
  30. array( 'db' => 'office', 'dt' => 'office' ),
  31. array(
  32. 'db' => 'start_date',
  33. 'dt' => 'start_date',
  34. 'formatter' => function( $d, $row ) {
  35. return date( 'jS M y', strtotime($d));
  36. }
  37. ),
  38. array(
  39. 'db' => 'salary',
  40. 'dt' => 'salary',
  41. 'formatter' => function( $d, $row ) {
  42. return '$'.number_format($d);
  43. }
  44. )
  45. );
  46. // SQL server connection information
  47. $sql_details = array(
  48. 'user' => '',
  49. 'pass' => '',
  50. 'db' => '',
  51. 'host' => ''
  52. );
  53. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  54. * If you just want to use the basic configuration for DataTables with PHP
  55. * server-side, there is no need to edit below this line.
  56. */
  57. require( 'ssp.class.php' );
  58. echo json_encode(
  59. SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns )
  60. );