Jaxel
02-10-2009, 08:44 PM
I'm working on that ranking script that I've been asking for the past couple of months...
One of the things I want to do, when I am calculating the rankings... I want to outdate older events... Events are all given a unix timestamp...
I am using the following code to calculate rankings... and so far its working great...
SELECT * FROM rank_scores
INNER JOIN rank_events ON(rank_scores.eventID = rank_events.eventID)
WHERE rank_scores.playerID = ".$player['playerID']."
ORDER BY sValue DESC, eDate DESC
As you can see, it takes all the earned scores that match a player's ID, from the rank_scores table (joined to the rank_event table), and sorts them by the highest earned scores and down (and additionally sorts by the event date). What I want to do is add in an extra WHERE statement... something along the lines of...
(currentTime - eDate) < $countDmod months
I defined the $countDmod variable as 12 in my config file. So what this should do, it will take the current date, subtract the date of the event from it... and if the remaining value is less than 12 months; it will add it to the SELECT statement, otherwise skip it.
How do I program this?
One of the things I want to do, when I am calculating the rankings... I want to outdate older events... Events are all given a unix timestamp...
I am using the following code to calculate rankings... and so far its working great...
SELECT * FROM rank_scores
INNER JOIN rank_events ON(rank_scores.eventID = rank_events.eventID)
WHERE rank_scores.playerID = ".$player['playerID']."
ORDER BY sValue DESC, eDate DESC
As you can see, it takes all the earned scores that match a player's ID, from the rank_scores table (joined to the rank_event table), and sorts them by the highest earned scores and down (and additionally sorts by the event date). What I want to do is add in an extra WHERE statement... something along the lines of...
(currentTime - eDate) < $countDmod months
I defined the $countDmod variable as 12 in my config file. So what this should do, it will take the current date, subtract the date of the event from it... and if the remaining value is less than 12 months; it will add it to the SELECT statement, otherwise skip it.
How do I program this?