Dynamically load the drop-down menu with the date so that it queries the database

advertisements

I know how to dynamically load a drop-down menu but my question is more around this problem...

I have a table that holds golf scores for players and the date that each player played that scorecard. So there may be for example; 20 scorecards played in 2015, and 20 scorecards played in 2014..what I want to do is dynamically populate the drop-down menu with only one option of 2014 and 2015. At the minute my drop-down is populating with 20 x 2015 and 20 x 2014.

SELECT YEAR(date) AS Date FROM leaderboard

Above is the SQL I am using to get the YEAR from Date in my table. Any suggestions how I could only show 1 option for each year in the drop-down menu?


SELECT DISTINCT YEAR(date) AS Date FROM leaderboard