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! 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? 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 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. 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
Archived
This topic is now archived and is closed to further replies.