Second, PHP paging class calling example:
1. Get the number of pages returned by the URL:
-
- $cur_page = 1;
- if (isset($_GET["pageNo"])) {
- $cur_page = $_GET["pageNo"];
- }
Copy code
2, Create pagination object:
-
- $nums: the total number of certain data
- $page_size: the number displayed on each page
- $cur_page: the current page number
- $request: other optional URL request parameters
- $pager = new Pager($nums, $page_size , $cur_page, $request);
Copy code
3, smarty assignment:
-
- $show = Get the data to be displayed
- $this->tpl->assign('numlink', $pager->nextPage()); // Get the paging list
- $this-> ;tpl->assign('data',$show);
Copy code
Pagination effect:

The above paging code does not implement url redirection, which exposes all the information passed in the address bar. You can improve it.
|