For the query, assuming you're using a MySQL database, you might try a SELECT DISTINCT query.
As Weedpacket said, it's just a matter of outputting some simple HTML (output the SELECT tag, loop through the SQL result set and output the OPTION elements as you go, then output the closing SELECT tag).