pixeltrace Posted November 20, 2007 Share Posted November 20, 2007 hi, i need help, i have a code in my form for the date select year currently its only showing 2001-2007, now my boss needs to add 2008 in my current code its only getting date from the current going to the 2001. hope you could help me change my code to get 2008 also. below is my code <select name="yearjoined"> <?php for($i=2001; $i<=date("Y"); $i++){ print '<option value="'.$i.'"'; if($yearText == $i){ print ' selected'; } print '>'.$i.'</option>'; } ?> </select> hope you could help me with this. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/78049-solved-need-help-in-my-select-year-code/ Share on other sites More sharing options...
pranav_kavi Posted November 20, 2007 Share Posted November 20, 2007 for($i=2001; $i<=)(date("Y")+1); $i++){ wont d abov work? Quote Link to comment https://forums.phpfreaks.com/topic/78049-solved-need-help-in-my-select-year-code/#findComment-395031 Share on other sites More sharing options...
PHP_PhREEEk Posted November 20, 2007 Share Posted November 20, 2007 <select name="yearjoined"> <?php for($i=2001; $i<=date("Y")+1; $i++){ print '<option value="'.$i.'"'; if($yearText == $i){ print ' selected'; } print '>'.$i.'</option>'; } ?> </select> or <select name="yearjoined"> <?php for($i=2001; $i<=2008; $i++){ print '<option value="'.$i.'"'; if($yearText == $i){ print ' selected'; } print '>'.$i.'</option>'; } ?> </select> PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/78049-solved-need-help-in-my-select-year-code/#findComment-395032 Share on other sites More sharing options...
pixeltrace Posted November 20, 2007 Author Share Posted November 20, 2007 thanks! that was a quick one and i didnt notice that. Quote Link to comment https://forums.phpfreaks.com/topic/78049-solved-need-help-in-my-select-year-code/#findComment-395037 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.