php - Auto populate HTML Select box with years past and future -


whats best way auto populate select box in form years in php.

i want able 15 years in past current year , 5 years in future current year.

i have looked around online , can find populate x amount of years

<?php $currentvalue = 2008; $past = 15; $future = 5; if ($currentvalue && ($currentvalue < date('y') - $past || $currentvalue > date('y') + $future)) {     echo "<option value=\"$currentvalue\" selected=\"selected\">$currentvalue</option>\n"; } ($year = date('y') - $past; $year <= date('y') + $future; $year++) {     if ($year == $currentvalue) {         echo "<option value=\"$year\" selected=\"selected\">$year</option>\n";     } else {         echo "<option value=\"$year\">$year</option>\n";     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -