Hi! I have three <select> elements that I use to enter data about day, month and year in a database. In a specific page of the site the user has the possibility to edit the date, and I would like the page to automatically select the correct elements of the menu based on the information in the database (so that, if the date inserted is 01-02-2011, the third <select> element would have the "2011" element already selected).

I was thinking about the following solution:

PHP Code:
//
// retrieve information from the database and save it in the variables $day, $month and $year
//

if ($year == '2011') {
  echo 
'<select>
            <option value="2011" selected="selected">2011</option>
            <option value="2012">2012</option>
          </select>'
;
else if (
$year == '2012') {
  echo 
'<select>
            <option value="2011">2011</option>
            <option value="2012" selected="selected">2012</option>
          </select>'
;

but is there a better way to do this?