1 |
35459
|
argiro.kok
|
<?php
|
2 |
|
|
|
3 |
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
4 |
|
|
* Easy set variables
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
// DB table to use
|
8 |
|
|
$table = 'datatables_demo';
|
9 |
|
|
|
10 |
|
|
// Table's primary key
|
11 |
|
|
$primaryKey = 'id';
|
12 |
|
|
|
13 |
|
|
// Array of database columns which should be read and sent back to DataTables.
|
14 |
|
|
// The `db` parameter represents the column name in the database, while the `dt`
|
15 |
|
|
// parameter represents the DataTables column identifier. In this case object
|
16 |
|
|
// parameter names
|
17 |
|
|
$columns = array(
|
18 |
|
|
array( 'db' => 'first_name', 'dt' => 'first_name' ),
|
19 |
|
|
array( 'db' => 'last_name', 'dt' => 'last_name' ),
|
20 |
|
|
array( 'db' => 'position', 'dt' => 'position' ),
|
21 |
|
|
array( 'db' => 'office', 'dt' => 'office' ),
|
22 |
|
|
array(
|
23 |
|
|
'db' => 'start_date',
|
24 |
|
|
'dt' => 'start_date',
|
25 |
|
|
'formatter' => function( $d, $row ) {
|
26 |
|
|
return date( 'jS M y', strtotime($d));
|
27 |
|
|
}
|
28 |
|
|
),
|
29 |
|
|
array(
|
30 |
|
|
'db' => 'salary',
|
31 |
|
|
'dt' => 'salary',
|
32 |
|
|
'formatter' => function( $d, $row ) {
|
33 |
|
|
return '$'.number_format($d);
|
34 |
|
|
}
|
35 |
|
|
)
|
36 |
|
|
);
|
37 |
|
|
|
38 |
|
|
// SQL server connection information
|
39 |
|
|
$sql_details = array(
|
40 |
|
|
'user' => '',
|
41 |
|
|
'pass' => '',
|
42 |
|
|
'db' => '',
|
43 |
|
|
'host' => ''
|
44 |
|
|
);
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
48 |
|
|
* If you just want to use the basic configuration for DataTables with PHP
|
49 |
|
|
* server-side, there is no need to edit below this line.
|
50 |
|
|
*/
|
51 |
|
|
|
52 |
|
|
require( 'ssp.class.php' );
|
53 |
|
|
|
54 |
|
|
echo json_encode(
|
55 |
|
|
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
|
56 |
|
|
);
|