Jump to content

[SOLVED] need help in my select year code


pixeltrace

Recommended Posts

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

                            <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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.