âš ī¸ Warning âš ī¸ Deprecated Code! This video tutorial contains outdated code.
💡 If you wish to update it, any AI assistant will update the code for you in seconds.

Dynamic Select Year List PHP Script HTML Form Tutorial

Published : November 22, 2014   •   Last Edited : November 24, 2025   •   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>