How does web development enable automatic page feed for posts? In addition, how does one enable content to be displayed only in one region? How does web development enable automatic page feed for posts? For example, when you set 10 posts and 11th posts, the switch page is like oschina. This is almost the same type. how can this problem be achieved? I don't know what I just learned. please give me some advice. You can also recommend some materials. Thank you. In addition, how can we design a rectangular area so that the post will be displayed in this area after it is published? do not go beyond this area, just like how to implement automatic page feed for posts in OS web development? And how to display the content in only one region
How does web development enable automatic page feed for posts? For example, if you set 10 posts and 11th posts, you can switch pages.
Like oschina. This is almost the same type. how can this problem be achieved? I don't know what I just learned. please give me some advice. You can also recommend some materials. Thank you.
There is also a way to design a rectangular area so that the post will be displayed in this area after it is published. do not go beyond this area.
Like oschina.
Share: More
------ Solution --------------------
$ Curpage = isset ($ _ GET ['curpage'])? $ _ GET ['curpage']: 1;
$ Total = 1000;
$ Pagesize = 20;
$ Url = 'Page. php ';
$ Show = 10;
Echo page ($ curpage, $ pagesize, $ total, $ url, $ show );
Function page ($ curpage, $ pagesize, $ total, $ url, $ show ){
If ($ total <= 0
------ Solution --------------------
$ Curpage <= 0
------ Solution --------------------
$ Pagesize <= 0
------ Solution --------------------
$ Show <= 0 ){
Return '';
}
$ Pagecount = (int) ($ total-1)/$ pagesize) + 1;
If ($ curpage> $ pagecount ){
$ Curpage = $ pagecount;
}
$ Tmp = '';
$ Step = (int) ($ show/2 );
If ($ curpage-$ step <= 0 ){
$ Start = 1;
$ End = $ pagecount> $ show? $ Show: $ pagecount;
} Elseif ($ curpage + $ step >=$ pagecount ){
$ Start = $ pagecount-$ show + 1;
$ End = $ pagecount;
} Else {
$ Start = $ curpage-$ step;
$ End = $ start + $ show-1;
}
If ($ curpage> 1 ){
$ Tmp. = 'previous page ';
}
For ($ I = $ start; $ I <= $ end; $ I ++ ){
If ($ I ==$ curpage ){
$ Tmp. = ''. $ I .'';
} Else {
$ Tmp. = ''. $ I .'';
}
}
If ($ curpage <$ pagecount ){
$ Tmp. = 'next page ';
}
$ Tmp. = 'Total: '. $ total.', total '. $ pagecount.' page ';
Return $ tmp;
}
?>