pixeltrace Posted March 31, 2007 Share Posted March 31, 2007 guys, can you help me with my drop down menu for year selectin my in my current codes its displays the year from 2001 to 2007 now what i wanted to happen is it will display the year from 2007 to 2001 this is my current code which displays the year from 2001 to 2007 hope you could help me with this. <?php for($i=2001; $i<=date("Y"); $i++){ print '<option value="'.$i.'"'; if($yearText == $i){ print ' selected'; } print '>'.$i.'</option>'; } ?> thanks! Quote Link to comment https://forums.phpfreaks.com/topic/45042-solved-display-current-year/ Share on other sites More sharing options...
AndyB Posted March 31, 2007 Share Posted March 31, 2007 <?php echo "<select name='year'>"; for($i=date("Y"); $i>=2001; $i--){ print '<option value="'.$i.'"'; if($yearText == $i){ print 'selected="selected"'; } print '>'.$i.'</option>'; } echo "</select>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/45042-solved-display-current-year/#findComment-218663 Share on other sites More sharing options...
pixeltrace Posted March 31, 2007 Author Share Posted March 31, 2007 thanks! everything is in order now! Quote Link to comment https://forums.phpfreaks.com/topic/45042-solved-display-current-year/#findComment-218668 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.