j007ha Posted September 26, 2008 Share Posted September 26, 2008 how am i going to generate a auto year drop down list by using php? For example : now the year is 2008, so i want the drop down list to generate a drop down list which consists the year before 3 and after 3 years of the year 2008. So what i want is <option>2005</option> <option>2006</option> <option>2007</option> <option>2008</option> <option>2009</option> <option>2010</option> <option>2011</option> i very very appreciate any help from u all ^^ Link to comment https://forums.phpfreaks.com/topic/125911-generate-year-drop-down-list/ Share on other sites More sharing options...
BlueStryke Posted September 26, 2008 Share Posted September 26, 2008 <select> <?PHP $year = date("Y") - 4; for ($i = 0; $i <= 6; $i++) {$year++; echo "<option>$year</option>";} ?> </select> Link to comment https://forums.phpfreaks.com/topic/125911-generate-year-drop-down-list/#findComment-651097 Share on other sites More sharing options...
BlueStryke Posted September 26, 2008 Share Posted September 26, 2008 Slightly less stupid way... sorry, it's 3am... XD <select> <?PHP $year = date("Y") - 3; for ($i = 0; $i <= 6; $i++) {echo "<option>$year</option>"; $year++;} ?> </select> P.S. - I would edit, but it doesn't let me anymore. Link to comment https://forums.phpfreaks.com/topic/125911-generate-year-drop-down-list/#findComment-651107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.