The so-called content paging refers to paging long content according to the tag you set. This article involves two areas, one is obtaining the address, there are a lot of paging tutorials on the Internet, but the addresses are fixed. if there is a comment page and the article ID called, it will be very troublesome, PHP100 video tutorial "> <LINKhref =" http://www.php100.com/
The so-called content paging refers to paging long content according to the tag you set. This article involves two areas, one is obtaining the address, there are a lot of paging tutorials on the Internet, but the addresses are fixed. if there is a comment page and the article ID called, it will be very troublesome, in this paper, the PHP100 video tutorial paging principle (http://www.php100.com/html/shipinjiaocheng/PHP100shipinjiaocheng/2009/0416/807.html) ideas, there are unclear shoes can see this tutorial, while using some content processing functions and array knowledge, I wrote such an article for the first time. sorry if the statement is unclear.
Let's take a look at it first:
For more paging effects, there are many such styles in the php100 Forum. here we will share the CSS style code in the image:
CSS:
- DIV.digg {PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; MARGIN: 3px; PADDING-TOP: 3px; TEXT-ALIGN: center}
- DIV.digg A {BORDER-RIGHT: #aaaadd 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #aaaadd 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #aaaadd 1px solid; COLOR: #000099; PADDING-TOP: 2px; BORDER-BOTTOM: #aaaadd 1px solid; TEXT-DECORATION: none}
- DIV.digg A:hover {BORDER-RIGHT: #000099 1px solid; BORDER-TOP: #000099 1px solid; BORDER-LEFT: #000099 1px solid; COLOR: #000; BORDER-BOTTOM: #000099 1px solid}
- DIV.digg A:active {BORDER-RIGHT: #000099 1px solid; BORDER-TOP: #000099 1px solid; BORDER-LEFT: #000099 1px solid; COLOR: #000; BORDER-BOTTOM: #000099 1px solid}
- DIV.digg SPAN.current {BORDER-RIGHT: #000099 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #000099 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #000099 1px solid; COLOR: #fff; PADDING-TOP: 2px; BORDER-BOTTOM: #000099 1px solid; BACKGROUND-COLOR: #000099}
- DIV.digg SPAN.disabled {BORDER-RIGHT: #eee 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #eee 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #eee 1px solid; COLOR: #ddd; PADDING-TOP: 2px; BORDER-BOTTOM: #eee 1px solid}
PHP code:
-
- $ Contents = "fjka; fjsa; # page # Generate [newpage] # page # component writing # page # parts and add # page # Paging code "; // original content with paging labels
- $ Cons = "fjka; fjsa; adsfasdfas code"; // The original content without the paging tag
-
- Function conpage ($ contents ){
- $ Pagesss = '# page #'; // sets the page tag.
- $ A = strpos ($ contents, $ pagesss );
- If ($ ){
- $ Con = explode ($ pagesss, $ contents );
- $ Cons = count ($ con );
- @ $ P = ceil ($ _ GET ['P']);
- If (! $ P | $ p <0) $ p = 1;
- $ Url = $ _ SERVER ["REQUEST_URI"];
- $ Parse_url = parse_url ($ url );
- $ Url_query = $ parse_url ["query"];
- If ($ url_query ){
- $ Url_query = ereg_replace ("(^ | &) p = $ p", "", $ url_query );
- $ Url = str_replace ($ parse_url ["query"], $ url_query, $ url );
- If ($ url_query) $ url. = "& p"; else $ url. = "p ";
- } Else {
- $ Url. = "? P ";
- }
- If ($ cons <= 1) return false; // only one page is displayed without pagination
- $ Pagenav = "";
- For ($ I = 1; $ I <= $ cons; $ I ++ ){
- If ($ I = $ p ){
- $ Pagenav. = ''. $ p .'';
- } Else {
- $ Pagenav. = "$ I ";
- }
- }
- $ Pagenav. = "";
- Return $ con [$ P-1]. $ pagenav;
- } Else {
- Return $ contents;
- }
- }
-
- Echo conpage ($ contents ); //
- Echo conpage ($ cons); //
-
- ?>
This article is PHP100 Chinese community original works, please reprinted with the source: http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2010/1201/6940.html