I'm using the following php/sql query to calculate the number of years between my earliest and most recent database records:
$query_years = mysql_query("SELECT YEAR(MAX(date)) - YEAR(MIN(date)) FROM locations");
This returns a single value and what i require instead is an array of all the YEARS in year order so that any year where there isn't a specific record for that year is omitted...
e.g. if my database had 2 records dated 1983 and 2008 - then it should just return these 2 years in chronological order, rather than all 25 years between the two dates.
- please can you show me how this is done?