Leaderboard based on stringy array in database
Posted: Tue Feb 23, 2010 7:35 pm
Hi there, im new here. My name is Karl, im 21 years old and have been using PHP since as long as i can remember.
I joined this forum hoping that I could get a little help
Basically, a website that I help do php coding for, has a feature where they can read a virtual item 'Book'.
The database is setup like the following :-
table: booksread
id / user_id / bookslist / bookstotal
bookstotal is an int that basically +1 everytime a book is read. Easy to order for a leaderboard for that.
bookslist is only added to when a unique book is read, it takes the id number of the book and appends it to the bookslist in the following form :-
concat('.$itemid.',bookslist)
So a books read would look something similar to :-
.23..35..13..11..1.163..1456..234..356..833.
I was thinking that I could order the rows in the query by the string length of the bookslist value,but could cause errors in the following way :-
.1..2.
.14245.
That scenario would think that the bottom one is longer than the top one.
Is there anything out there I could do to make it so that I can order this correctly?
Thanks in advance
Karl
I joined this forum hoping that I could get a little help
Basically, a website that I help do php coding for, has a feature where they can read a virtual item 'Book'.
The database is setup like the following :-
table: booksread
id / user_id / bookslist / bookstotal
bookstotal is an int that basically +1 everytime a book is read. Easy to order for a leaderboard for that.
bookslist is only added to when a unique book is read, it takes the id number of the book and appends it to the bookslist in the following form :-
concat('.$itemid.',bookslist)
So a books read would look something similar to :-
.23..35..13..11..1.163..1456..234..356..833.
I was thinking that I could order the rows in the query by the string length of the bookslist value,but could cause errors in the following way :-
.1..2.
.14245.
That scenario would think that the bottom one is longer than the top one.
Is there anything out there I could do to make it so that I can order this correctly?
Thanks in advance
Karl