One choice for each year from last year to five years from now : Form Select « Form « PHP






One choice for each year from last year to five years from now

 
<?
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 
                5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
                9 => 'September', 10 => 'October', 11 => 'November', 
                12 => 'December');

print '<select name="year">';
for ($year = date('Y') -1, $max_year = date('Y') + 5; $year < $max_year; $year++) {
    print '<option value="' . $year . '">' . $year ."</option>\n";
}
print "</select> \n";
?>
  
  








Related examples in the same category

1.Form select input
2.An HTML Form Including a SELECT Element
3.A
4.A day choice
5.An HTML Form with a select Element
6.Validating a drop-down menu with in_array()
7.Displaying a
8.Generating a dynamic pull-down menu
9.Setting a default value in a
10.Setting defaults in a multi-valued
11.Creating Form Elements Based on the Current Time and/or Date
12.Creating Form Elements with Multiple Options
13.One choice for each day from 1 to 31