phpretard Posted February 9, 2009 Share Posted February 9, 2009 how can turn this into dynamic code without typing all the options? I would like: $start_year = date('Y'); $end_year = $start_year -80 years <select name="DateOfBirth_Year"> <option> - Year - </option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> </select> Link to comment https://forums.phpfreaks.com/topic/144426-solved-birthyear/ Share on other sites More sharing options...
sasa Posted February 9, 2009 Share Posted February 9, 2009 <select name="DateOfBirth_Year"> <option> - Year - </option> <?php $start_year = date('Y'); $end_year = $start_year - 80; for ($year = $start_year; $year >= $end_year; $year--){ echo "\t<option value=\"$year\">$year</option>\n"; } ?> </select> Link to comment https://forums.phpfreaks.com/topic/144426-solved-birthyear/#findComment-757869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.