In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to turn the page in php". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to turn pages in php".
Php to achieve paging methods: 1, query all the conditions need to be paged the total data, calculate the total number of pages displayed; 2, access to the current display is the number of pages of information; 3, according to restrictions to query the current page needs to display the data; 4, each piece of data echo to replace HTML structure content, the final display can be.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
How to turn the page with php?
Php realizes the process of turning the page from one page to the next page in detail
This article mainly introduces php to realize the process of turning the next page on the web page in detail, the general function is that the page only displays a few pieces of information, press the previous page and the next page to switch content, when the first page is displayed, the previous page and home page options are not optional, when the page is loaded to the last page, the next page and the last page options are not optional, friends who need can refer to the next page.
Preface
These days, because there is too much data, I need to display the information up and down the page, so I write the code to turn the page.
The general function is that the page displays only a few pieces of information, and the content is switched by the previous page and the next page. The previous and first page options are not selectable when the first page is displayed, and the next and last page options are not selectable when the page is loaded to the last page.
The specific effects are as follows:
Implementation code
1) Native PHP method
First of all, let's talk about the general idea. first of all, we have to query all the total data that meet the requirements for paging and calculate the total number of pages displayed.
Then get the information of which page is currently displayed, express the number of pieces of data per page as the number of total data, and then query the data to be displayed on the current page according to the restrictions. Replace each piece of data in the HTML structure with echo, and finally display it.
The restrictions on paging are simple, as long as the query to the current page is page 1, the first page and the previous page option jump links are fixed on the first page while setting the option disabled is not optional, the last page is the same step.
The specific code is as follows:
The cPage of the current page needs to be passed. My solution is the initial cPage=0.
List.php*
More > > $row=$table- > fetch () reads one message at a time to get an indexed array. The $row ['id'] in the code represents the value named id in $row, or $row.id.
Connect.php (connect to database)
Turn the page up and down:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.