I'm building something very similar at the moment, but a lot of the functionality is spread over many, many classes and files, so this is about the only thing i can find which may help rather than confuse you. It returns an HTML selectbox called $name, with the options in array $items.
If you make a few of these, one for year, month and day, with the current date selected, you are guaranteed valid data you can use:
$years = array( '2002' => 2002,
'2003' => 2002,
'2004' => 2004,
etc... );
$months = array( 'Jan' => 1,
'Feb' => 2,
etc... );
$days = range(1,31);
$year = get_dropdown( 'year', $years, 2002 );
$mnth = get_dropdown( 'month', $months, 10 );
$day = get_dropdown('day', $days, 13 );
/**
* Generates and returns a pulldown menu for a form.
*
* @access public
* @param string $name
* @param array $items Array of options. Title => value.
* @param string $selected Value of selected item in array $items.
* @return string
*/
function get_dropdown( $name, $items, $selected )
{
$content = "<select name=\"$name\" id=\"$name\">";
foreach ( $items as $title=>$value ) {
$content .= "<option value=\"$value\" ";
if ( $selected == $value ) {
$content .= 'selected="selected"';
}
$content .= ">$title</option>";
}
$content .= "</select>";
return $content;
}