PHP paging: how does one implement Baidu paging?
Reply to discussion (solution)
I have no question...
The page size should be almost the same. baidu also passed a parameter & pn = 0.
Determine the page number based on the pn value and take a footprint for image processing? And so on.
If you are talking about 1 2 3 4 5 display
Paging procedure
1. calculate the total number of items
2. get the current page
3. calculate the total number of pages ceil (total number of pages/Number of pages per page)
4. the calculated offset is limit n, m
5. query data display data
Note: The third part shows the total number of pages. suppose it is 10 pages.
$str = ''; for($i=1;$i<=10;$i++){ str .= ''.$i.''; }echo $str;
In this way, the 12345 effect will come out.
Then click style.
a{ width:20px; height:20px; display:block; background:#ffffff; border:1px dashed #ccc; color:blue;}a:hover{ background:blue;}
It's almost so sloppy.
If you are talking about 1 2 3 4 5 display
Paging procedure
1. calculate the total number of items
2. get the current page
3. calculate the total number of pages ceil (total number of pages/Number of pages per page)
4. the calculated offset is limit n, m
5. query data display data
Note: The third part shows the total number of pages. suppose it is 10 pages.
$str = ''; for($i=1;$i<=10;$i++){ str .= ''.$i.''; }echo $str;
In this way, the 12345 effect will come out.
Then click style.
a{ width:20px; height:20px; display:block; background:#ffffff; border:1px dashed #ccc; color:blue;}a:hover{ background:blue;}
It's almost so sloppy.
How does Baidu calculate the page number range?
Currently, 1 ~ is displayed before 7 ~ 10
Current page 7 2 ~ 11
...
Current page 10 5 ~ 14
How is this calculated?
Very easy. I recently made a paging-proficient ppt. you can share it with me.
If you are talking about 1 2 3 4 5 display
Paging procedure
1. calculate the total number of items
2. get the current page
3. calculate the total number of pages ceil (total number of pages/Number of pages per page)
4. the calculated offset is limit n, m
5. query data display data
Note: The third part shows the total number of pages. suppose it is 10 pages.
$str = ''; for($i=1;$i<=10;$i++){ str .= ''.$i.''; }echo $str;
In this way, the 12345 effect will come out.
Then click style.
a{ width:20px; height:20px; display:block; background:#ffffff; border:1px dashed #ccc; color:blue;}a:hover{ background:blue;}
It's almost so sloppy.
How does Baidu calculate the page number range?
Currently, 1 ~ is displayed before 7 ~ 10
Current page 7 2 ~ 11
...
Current page 10 5 ~ 14
How is this calculated?
Assume that the current page number is $ page.
$ First_page = max ($ page-5, 1 );
$ End_page = $ first_page + 9;