Jump to content

see which user got the most points in a MONTH


jwk811

Recommended Posts

in the user table there is a row called user_score. points get added to their score doing various things on the site.

 

theres no way of telling how many points they got in a month right now. and i dont know what the easiest way of doing that would be. maybe a new table keeping track but then how should it be updated.

 

any ideas? thanks.

Link to comment
Share on other sites

You should have a separate table to record each instance of an activity that adds to their points with: userID, date, points, activity. You can then get a user's total points by doing a JOIN between the user table and the points table. You can then also get a users points by some arbitrary value (such as a date span) or by activity via the WHERE clause

 

example:

SELECT u.name, u.id,
       SUM(p.point) as totalPoints
FROM users u
JOIN points p ON u.id = p.user_id
WHERE u.id = {$userID}
  AND p.date > {$startDate}
  AND p.date < {$endDate}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.