-
Notifications
You must be signed in to change notification settings - Fork 9
/
getOrderList.php
40 lines (38 loc) · 1.03 KB
/
getOrderList.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
37
38
39
40
<?php
/**
* Encoding : UTF-8
* Created on : 2015-10-13 15:25:07 by caowenpeng , caowenpeng1990@126.com
* @link http://blog,rc5j.cn 博客地址
*
*/
$conn = new mysqli('localhost', 'root', '123456', 'test');
$conn->query('SET NAMES UTF8');
$page = $_POST['page'];
$pageSize = $_POST['rows'];
$sort = $_POST['sord'];
$order = $_POST['sidx'];
$offset = ($page - 1) * $pageSize; //分页起始条数
$sql = "select * from employee order by $order $sort limit $offset, $pageSize";
$result = $conn->query($sql);
$rows = [];
if ($result) {
$nums = $result->num_rows;
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
}
if ($nums > 0) {
$total_pages = ceil($nums / $pageSize);
} else {
$total_pages = 0;
}
$arr_json = array('page' => $page, 'total' => $total_pages, 'records' => $nums, 'rows' => $rows);
ajaxReturn($arr_json);
/**
*
* @param array $data
*/
function ajaxReturn(array $data) {
header('content-type:application/json;charset=utf8');
exit(json_encode($data, JSON_UNESCAPED_UNICODE));
}