Hi could someone please help me with more SQL. I have a number of records with different years, 2005, 2002, 2001 etc etc. There are also lots of records with the same year. How would i go about getting all the unique dates from the database and then listing them in a drop down box, so that a user could select to see all the records from that year. Thanks in advance, Andy
Try: Code: $query = 'SELECT DISTINCT field_name FROM table_name ORDER BY whatever'; $result = mysql_query($query,$dbconn); // where $dbconn is your connection string echo '<select name="years">'; while($a_row = mysql_fetch_array($result)) { echo '<option>'. $a_row['field_name'] .'</option>'; } echo '</select>'; Hope this helps
Hmmm.. Interesting. I wasn't aware of the DISTINCT switch in the sql query. Over that, I really need to learn php.