Forum Moderators: coopster

Message Too Old, No Replies

Lost with Pagination

         

dkin

1:12 am on Jan 24, 2005 (gmt 0)

10+ Year Member



The problem that I am having is that I have a game I am creating, in the game users are ranked and can attack other users, when the user chooses to attack I want other users displayed in a loop, this works fine, but I would like the user who is attacking to be at the top of the list, and I only want 100 to be able to be viewed higher or lower then that users rank.

So, say our user is rank 1000 then I want 50 on the default page (user at the top) 2 pages of players ranked higher and two pages of users ranked lower.

If this is possible i would appreciate some help, thank you.

Cheers

jatar_k

7:35 pm on Jan 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if we are doing this on rank then

first get the user info and rank
select * from usertable where username='somename'

get the rank from that row, assign it to a var (say userrank) and I would probably start by using 2 seperate queries

select username,rank from usertable where rank < userrank order by rank desc limit 50

then you can do

select username,rank from usertable where rank > userrank order by rank asc limit 50