forked from gea-ecobricks/ecobricks-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-ecobricks.php
More file actions
120 lines (91 loc) · 2.99 KB
/
ajax-ecobricks.php
File metadata and controls
120 lines (91 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/*
* DataTables example server-side processing script.
*
* Please note that this script is intentionally extremely simple 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 http://datatables.net/usage/server-side for full details on the server-
* side processing requirements of DataTables.
*
* @license MIT - http://datatables.net/license_mit
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
// DB table to use
$table = 'vw_ecobricks_desc';
// Table's primary key
$primaryKey = 'serial_no';
// 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
$columns = array(
array( 'db' => 'ecobrick_full_photo_url',
'dt' => 0,
'formatter' => function( $d, $row ) {
return '<a href="'.($d).'"</a><img src="'.($d).'" width="100px" alt="Ecobrick preview pic"/></a>';
}
),
array(
'db' => 'date_logged_ts',
'dt' => 1,
'formatter' => function( $d, $row ) {
return ''.date($d).'';
// return '<var>'.date( 'jS M y', strtotime($d)).'</var>';
}
),
array( 'db' => 'weight_g',
'dt' => 2,
'formatter' => function( $d, $row ) {
return '<var>'.($d).' g</var>';
}
),
array( 'db' => 'owner', 'dt' => 3 ),
array( 'db' => 'ecobrick_brk_amt',
'dt' => 4,
'formatter' => function( $d, $row ) {
return '<var>'.number_format($d,2).' ß</var>';
}
),
array(
'db' => 'CO2_kg',
'dt' => 5,
'formatter' => function( $d, $row ) {
return '<var>'.number_format($d,2).' kg</var>';
}
),
array( 'db' => 'serial_no',
'dt' => 6,
'formatter' => function( $d, $row ) {
return '<a href="details-ecobrick-page.php?serial_no='.($d).'">'.($d).'</a>';
}
),
);
/*
array( 'db' => 'serial_no',
'dt' => 7,
'formatter' => function( $d, $row ) {
return '<a href="details-ecobrick.php?serial_no='.($d).'">'.($d).'</a>';
}
),
*/
// SQL server connection information
$sql_details = array(
'user' => 'ecobricks_russs',
'pass' => '1ecobricks!',
'db' => 'ecobricks_gobrik_msql_db',
'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 )
);
?>