php
query("SELECT count(id) as total FROM table")->fetchColumn();
$limit = 10; // 每页显示数量
$totalPages = ceil($total / $limit); // 总页数
if (isset($_GET['page'])) {
$currentPage = $_GET['page'];
} else {
$currentPage = 1;
}
$offset = ($currentPage - 1) * $limit;
$data = $pdo->query("SELECT * FROM table LIMIT $offset, $limit")->fetchAll();
echo json_encode(array(
'totalPages' => $totalPages,
'data' => $data
));
?>
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-