title: Creating array from MYSQL 'datetime' of years available
body: <p>I have looked around for a simple solution to this question but I can't seem to find one. What I have is a database full of timestamped date and would like to be able to pull out all the years and list them. For example I have the following data under 'date':</p>
  
  <pre><code>2014-11-19 19:58:07
  2015-10-14 18:58:05
  2014-09-05 04:28:02
  2014-10-01 05:58:00
  2017-01-20 18:48:00
  2014-03-20 07:58:00
  </code></pre>
  
  <p>And would like to print only the following (if in database, with no repeats):</p>
  
  <pre><code>2014
  2015
  2017
  </code></pre>
  
  <p>Any help would be greatly appreciated thanks!</p>
  
  <p>Edit: Sorry I'm pretty new to this I have "</p>
  
  <pre><code>$query="SELECT DISTINCT YEAR(date) FROM database;";
  $result=mysql_query($query);
  $numd=mysql_numrows($result);
  echo $num;
  </code></pre>
  
  <p>and it prints:</p>
  
  <pre><code>3
  </code></pre>
  
  <p>but I would like it to print:</p>
  
  <pre><code>2014
  2015
  2017
  </code></pre>
  
  <p>Thanks</p>