Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the simple and practical native PHP paging class?

Shulou Source: shulou.com Published: 2022-06-03 03:55:23 10月06日 Update

This article shows you what the simple and practical native PHP paging class is like, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

A simple and practical native PHP paging class, the paging button style is simple and beautiful, and displays "..." when there are many pages, which is also the effect used by many websites.

Core paging code

Include_once ("config.php"); require_once ('page.class.php'); / / paging class $showrow = 10; / / number of rows displayed on a page $curpage = empty ($_ GET [' page'])? 1: $_ GET ['page']; / / the current page should also handle non-numeric cases $url = "? page= {page}" / / paging address, if there is a search condition = "? page= {page} & Q =". $_ GET ['q'] / / omits the code for linking mysql, add $sql = "SELECT id,content,addtime FROM wishing_wall" during the test; $total = mysql_num_rows (mysql_query ($sql)) / / the total number of records if (! empty ($_ GET ['page']) & $total! = 0 & & $curpage > ceil ($total / $showrow)) $curpage = ceil ($total_rows / $showrow); / / the current number of pages is greater than the last number of pages, take the last page / / get the data $sql. = "LIMIT". ($curpage-1) * $showrow. ", $showrow;"; $query = mysql_query ($sql)

Paged list data display

Show paging button

The above is what the simple and practical native PHP paging class looks like. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Utility code content skills buttons data knowledge number of pages concise concise beautiful concise address that is situations effects numbers articles times more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Redmi NVidia MariaDB