Make a dynamic year dropdown using PHP
Ever wanted to have a dropdown that automatically showed the current year and the few years before it?
This is a quick and easy way to do exactly that!
1 2 3 4 5 6 7 8 <select name="year"> <?php for($i=date("Y")-5;$i<=date("Y");$i++) { $sel = ($i == date('Y')) ? 'selected' : ''; echo "<option value=".$i." ".$sel."-->".date("Y", mktime(0,0,0,0,1,$i)).""; } ?> </select>