-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.php
More file actions
43 lines (33 loc) · 797 Bytes
/
action.php
File metadata and controls
43 lines (33 loc) · 797 Bytes
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
<?php
require_once 'config.php';
require_once 'DB.php';
define('PAGE_SIZE', 5);
/**
* 获取留言列表
* @return [type] [description]
*/
function get_page_list($page) {
if(!isset($page) || is_null($page)) $page = 1;
return _get_for_page("select * from ex_guestbook", $page);
}
/**
* 获取分页数据
* @param [type] $sql [description]
* @param [type] $page [description]
* @return [type] [description]
*/
function _get_for_page($sql, $page = 1) {
$offset = ($page - 1) * PAGE_SIZE;
$db = new DB();
return $db->query($sql . " limit $offset, ".PAGE_SIZE);
}
/**
* 获取留言总数
* @return [type] [description]
*/
function get_page_count() {
$db = new DB();
$count = $db->get("select count(0) from ex_guestbook");
return ceil($count / PAGE_SIZE);
}
?>