Hi - I have a problem that hopefully can be easily resolved.
I have an Events table in MYSQL with 'start_date' and 'end_date' fields. Data in these fields are in UNIX_TIMESTAMP format.
I wanted to create a dropdown list showing DISTINCT months and/or years from all records using the 'start_date' data.
Drop down might look like this:
Jan - 2003 --- Might be 5 records in here
Mar - 2003 --- Might be 2 records in here
Oct - 2003 --- Might be 23 records in here
Feb - 2004 --- Might be 1 record in here
So, any ideas how I select distinct months and/or years from a UNIX_TIMESTAMP stored in MYSQL table???
I have this so far...
<?php
////////////////////////////////////////////////////////////////////
// Dynamic drop down list for Months with Events //
////////////////////////////////////////////////////////////////////
?>
<select name="event_month" class="forms-inputbox" id="event_month">
<?php
$query = "SELECT DISTINCT start_date FROM events ORDER BY start_date";
$result = mysql_query($query, $link);
if(mysql_num_rows($result)) {
while($row = mysql_fetch_row($result))
{
$monthyear[0] = date("M - Y",$row[0]);
print("<option value=\"$row[0]\">$monthyear[0]</option>\n");
}
} else {
print("<option value=\"\">Error</option>");
}
?>
</select>
This is what I get...

...there are 8 events in August and so August - 2003 is repeated 8 times...so any idea how I can show only DISTINCT dates...?