FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Dynamic Select Year List PHP Script HTML Form Tutorial

Published :
Author :
Adam Khoury
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>