PHP code example of hyacinth / page
1. Go to this page and download the library: Download hyacinth/page library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hyacinth / page example snippets
use HyacinthTechnology\Pager;
/*
* 数据分页
* $page 当前页数
* $PageCount 数据库查询的总记录数
*/
function pager($page,$PageCount){
$pag = new Pager();
$pag->AbsolutePage = $page; //当前锁定页
$PageCount = ($PageCount + 10 - 1) / 10; //计算页数
$pag->PageCount = intval($PageCount); //总页数量
// $pag->FirstPageLink = '/home/1'; //首页链接
$pag->Size = 10; //页码尺寸
/*
* ToString(参数)
* 1 分页
* 2 简易分页
* 3 只显示、上一页和下一页
*/
$pageCodeHtml = $pag->ToString(1); //获得分页过后的html
echo $pageCodeHtml; //将输出以下内容
}
//接受页面传递过来的页码
$pager = $_GET['page'];
pager($pager,150);