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 ^^ Quote Link to comment 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> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.