Return to Snippet

Revision: 1319
at September 27, 2006 11:38 by gdonald


Updated Code
function getYearOptions( $selected, $offset, $count )
{
    $options = '';

    $start_year = date( 'Y' ) + $offset;

    $finish_year = $start_year + $count;

    for( $x = $start_year; $x <= $finish_year; $x++ )
    {
        if( strlen( $x ) == 1 ) $x = '0' . $x;

        $options .= '<option value="' . $x . '"';

        if( $x == $selected )
        {
            $options .= ' selected="selected"';
        }

        $options .= '>' . $x . '</option>';
    }

    return $options;
}

Revision: 1318
at September 27, 2006 11:38 by gdonald


Initial Code
function getYearOptions( $selected, $offset, $count )
{
    $options = '';

    $start_year = date( 'Y' ) + $offset;

    $finish_year = $start_year + $count;

    for( $x = $start_year; $x <= $finish_year; $x++ )
    {
        if( strlen( $x ) == 1 ) $x = '0' . $x;

        $options .= '<option value="' . $x . '"';

        if( $x == $selected )
        {
            $options .= ' selected="selected"';
        }

        $options .= '>' . $x . '</option>';
    }

    return $options;
}

Initial URL

                                

Initial Description

                                

Initial Title
PHP year options

Initial Tags

                                

Initial Language
PHP