forked from jeffdupont/bootstrap-data-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-data.php
36 lines (27 loc) · 1019 Bytes
/
example-data.php
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
<?php
$total_rows = 200;
$per_page = $_POST["perPage"] ?: 10;
$current_page = $_POST["currentPage"] ?: 1;
$sort = $_POST["sort"] ?: array(array( "column_0", "desc" ), array( "column_2", "asc" ));
$filter = $_POST["filter"] ?: array("column_0" => "foo");
$example = array(
"totalRows" => $total_rows,
"perPage" => $per_page,
"sort" => $sort,
"filter" => $filter,
"currentPage" => $current_page,
"data" => array(),
"posted" => $_POST
);
for($i = 1; $i <= $per_page; $i++) {
$current_row = ($current_page * $per_page) - $per_page + $i;
if($current_row > $total_rows) break;
$example["data"][] = array(
"column_0" => "row: " . $current_row . " column 1 " . rand(0,100),
"column_1" => "row: " . $current_row . " column 2 " . rand(0,100),
"column_2" => "row: " . $current_row . " column 3 " . rand(0,100),
"column_3" => "row: " . $current_row . " column 4 " . rand(0,100),
);
}
// header('Content-type: text/json');
echo json_encode($example);