i recently implemented pagination in my project. be frank, it is not one page solution.
I can share idea with you, try to implement in your code
pagination based on these variables TotalNoOfPage,noOfRow and pageCount ;
1) TotalNoOfPage : Do the query in database using count(*) to find out how many rows are possible
2) noOfRow : rows to display in a single page.
3) pageCount : request page no.
Working Logic :
lets assume noOfRow = 25, so in first page display 25 rows by limiting now of rows from query (use LIMIT or equivalent keyword in sql )
at bottom logic to provide nos is bit complex, count no of pages by (noOfRow /noOfRow ), run for loop to display numbers,provide href with pageno at bottom
lets say 1(pageCount =1) ,2(pageCount =2) .....................5(pageCount =5) .............10(pageCount =10)
let say user click on link 5
in back end you got the pageCount value as 5, now you now that you have to fetch rows from 100 - 125
I agree with your answers, but I feel that hitting database for each 100 records is also a costly process.
I google for pagination and found display tags third party API, don't know in what way it is functioning internally. It seems like it is getting all the available records from database and displaying in the browser
Is there any thrid party API which functions as per your explanation, like fetching only 100 or 1000 records per page each time?
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
Any database access is a relatively costly process. But grabbing more data than you need is more costly than just grabbing what you need.
If your application is such that you are sure and have proved that people will always look at the next "page" of data, you might want to do some measure of pre-fetch and caching -- but that's the type of thing you should only do after determining that it will be helpful. Anything else is premature.