Welcome Guest, Not a member yet? Register   Sign In
User Ranking / User Level
#1

[eluser]RaZoR LeGaCy[/eluser]
Hello,

I already have a user auth system in place. I am a little confused on how to go about programming a user level logic. Currently I just run a basic division logic on a total. I want a system where for example, level 1 = 200pts, level 2 = 500pts, level 3 = 900pts, or something similar. Simply what is the logic I should use here or where can I reference this in a php class on the net?
#2

[eluser]dchuk[/eluser]
You might want to reference StackOverflow's ranking system, they did a really good job with it.

If you created different levels in a separate database table, you'd be able to reference a user's score to find their rank and also independently modify the ranking system without having to update all of the users simultaneously. Just a thought.
#3

[eluser]RaZoR LeGaCy[/eluser]
What would an example of the DB look like. I think I am getting you here but still unsure. Separate table for users score and another for the levels I set. Then I take the score and run query that says if score is between two numbers, but I think that query doesn't make sense. Unsure how to write that query as well. I was trying to dig through PHPBB but that yielded nothing but a migraine.

So close to the logic, a little more please.
#4

[eluser]dchuk[/eluser]
well, the way I would do it is for each user level, store a minimum score and a maximum score (like 1-99, 100-199, etc. Then, load up the current user's score (that doesn't need to be a separate table in my opinion, unless you're saving each individual reason why they earned points and then totaling it. If you just need a running tally, save it in a column in the users table).

run a query like this to get the current user's level:

$this->db->where('max_score >', $user_score);
$this->db->where('min_score <', $user_score);
$query = $this->db->get('scores_table');
#5

[eluser]RaZoR LeGaCy[/eluser]
Hey dchuck,

Much thanks, this seems soo simple but of course I always over think things. Is there a mathematical way to calculate level accordingly.

currently $user_score = number_format((($user_baseScore) + ($user_videoViews/100) + ($user_friendsMade/30)), 2, '.', '');
ex $user_score = number_format((($user_baseScore) + ($user_videoViews/100) + ($user_friendsMade/30)), 2, '.', '') * ($userInfo['userScore'] / 100);

Is that the right logic?




Theme © iAndrew 2016 - Forum software by © MyBB