Forum Moderators: coopster

Message Too Old, No Replies

Digg like paging - how to do it!?

Digg like paging - how to do it!?

         

bloggy

1:23 am on Nov 4, 2007 (gmt 0)

10+ Year Member



Hi all,

can anybody tell me how to do or where to find such a paging script like the digg paging:

I have a mysql database with hundreds of records and I want to show 10 items per page. And I also would like to have that not ALL the numbers are shown because I have thousands of items in the database.

Thanks for your help in advance! :)

[edited by: jatar_k at 1:28 am (utc) on Nov. 4, 2007]
[edit reason] no urls thanks [/edit]

FourDegreez

3:44 pm on Nov 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



select count(*) from the table, and divide that number by the number of items per page, and that's how many pages you've got--actually, it's ceil(count / items per page). Then whatever page the user is currently viewing, show links to several pages before and after it, plus the first and last page. You need special handling if the user is viewing pages all the way at the end or the beginning (so you don't show links for pages number -1, -2, etc).

To select the actual items on that page, use LIMIT and OFFSET. Example: SELECT a, b, c FROM xyz LIMIT 10 OFFSET 20

The limit is how many items to show per page, offset is (page number - 1) * items per page.