Auto Populate Years Range In PHP
August 7th, 2008 | by King | Posted in » Form, Useful Scripts
In forms its better approach to populate years drop down list rather then writing down every year manually. This script will ask you starting year and rest of years up till latest year it will populate for you.
<?php $currentYear = date("Y"); $years = range ($currentYear, 1900); echo '<select>'; foreach ($years as $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; ?>
