How to add pagination Using PHP? -


i using api , have access current page url , final page url ,

i current page url $page , , final page url $total ,

i next page $page + 1 ,

i need display post navigator

<< 1 2 3 4 5 .... 190 >> 

assuming 190 final page ,

the problem when reach page 190 , pagination show << 190 191 192 193 194 ... 190 >>

how can fixed 190 final page , need display pages before , , disable >> next ,

same in case of page 1 , need disable << button ...

all page data served using $_get requests , pages same ... no seperate home page or ending page ...

you need calculate start page, end page , iterate on them.

for example, first page should start 1 till 5, 5 less, maximal page (190), should add "..." , 190. however, because start page 1, should not allow "<<" link.

if on page 190, end page 190 + 5 = 195. maximum page 190, set end page. so, start page end page - 5: 190 - 5 = 185. because end page maximal page, disable ">>" link. because 185 more 1, add "..." , 1.

everything other small details of algorithm better look.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -