Hosting Solutions
mobile_logo Table of Contents

Dynamic Select Year List PHP Script HTML Form Tutorial

Use PHP to program dynamic year select lists in HTML forms to avoid the need to write up to 100 lines in your HTML. The PHP loop will write the options for you in a for loop. We can do this easily because years are numeric and incremental. Adding the final year dynamically allows you to die as the programmer but still appear as if you are still updating your form every year. <!DOCTYPE html> <html> <body> <select id="year" name="year"> <?php for($i = 1900; $i < date("Y")+1; $i++){ echo '<option value="'.$i.'">'.$i.'</option>'; } ?> </select> </body> </html>

PHP Videos

Programming Forms

Multiple Select HTML Form Fields PHP Parse TutorialDynamic Select Year List PHP Script HTML Form TutorialEmail Address Validate 4 Levels JavaScript PHP Verify