<select name='last_year_attended'>
<option value=''>Select one...</option>
<?php
for ($start_yr=1971;$start_yr<2012;$start_yr++) {
$end_yr=$start_yr+1;
echo "<option value='".$start_yr."-".$end_yr.">".$start_yr."-".$end_yr."</option>";
}
?>
</select>
The problem:
I need this thing to give me a dropdown list of years in one-year increments:
1971-1972
1972-1973
1973-1974
1974-1975
and so on and so forth.
Instead, it is giving me a dropdown list of years in two-year increments:
1972-1973
1974-1975
1976-1977
1978-1979
and so on and so forth.
By my logic, $start_yr is being incremented by one with each iteration of the loop, so why is it echoing two year spans instead of one year spans?
I know this is something simple and my mush mind is just missing it.
Your help is greatly appreciated.

New Topic/Question
Reply






MultiQuote






|