Page 1 of 1

user list

Posted: Thu Sep 15, 2011 5:58 pm
by stefans
Hello all,
So i want to make a user list.. (i know how to make this)
but i want it to be more pages, so 20 users to page, how exactly do i do that? because i've never done that before =p

Thanks for the help =D

Re: user list

Posted: Thu Sep 15, 2011 6:09 pm
by Xaleph
It`s called pagination. The idea is that if the limit is 20, you only query 1 to 20 for the first page, if you go to the next page, you pass a parameter ( the pagination number ) that measures the offset.

So pagination number 1 is: 1 * 20 for the first, 1 * 20 + 20. 20 - 40
So pagination number 2 is: 2 * 20 for the first, 2 * 20 + 20. 40 - 60
So pagination number 3 is: 3 * 20 for the first, 3 * 20 + 20. 60 - 80

You can limit your query`s using the LIMIT keyword. Like "SELECT username, score FROM users LIMIT 20, $offset".

Re: user list

Posted: Thu Sep 15, 2011 6:26 pm
by stefans
Ok thank you =)