/** * 自定义分页方法 * @param unknown_type $url #分页url,页码采用'%s'表示,例如:http://test.ebers.com/tags/xxx/%s/ * @param unknown_type $cur_page #当前页码 * @param unknown_type $page_fix #当前页码前后需要显示多少个页码 * @param intval $total_rows #数据总数 * @param intval $pagesize #每页显示多少数据 * @param string $cur_page_calss #当前页css样式名称 */ public function pagenation($url, $cur_page=1, $page_fix=2, $total_rows=0, $pagesize=10, $cur_page_calss='disable'){ #计算总页数 $pagesize = $pagesize>0?$pagesize:10; $total_page = ceil($total_rows / $pagesize); $code = ''; if($total_page>1){ $pager = array(); #首页 $pager[] = sprintf( '<ul><li><a href="%s">首页</a></li>', sprintf($url, 1) ); #页码列表 for($page_num=$cur_page-$page_fix; $page_num<$cur_page+$page_fix; $page_num++){ if($page_num<1 || $page_num>$total_page){ continue; } $pager[] = sprintf( '<li class="%s"><a href="%s">%s</a></li>', ( $page_num==$cur_page?$cur_page_calss:'' ), sprintf($url, $page_num), $page_num ); } #末页 $pager[] = sprintf( '<li><a href="%s">末页</a></li><li>共%s条,第%s/%s页</li></ul>', sprintf($url, $total_page), $total_rows, $cur_page, $total_page ); $code = implode("\n", $pager); unset($pager); } return $code; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools