Skip to content

Instantly share code, notes, and snippets.

@prio101
Created April 3, 2015 04:54
Show Gist options
  • Select an option

  • Save prio101/5173dfe5d03c5acf98ea to your computer and use it in GitHub Desktop.

Select an option

Save prio101/5173dfe5d03c5acf98ea to your computer and use it in GitHub Desktop.
Year Option maker in select form.
<select name="pickYear">
<option value="1980"<?php echo $pickYear == '1980' ? 'selected' == "selected" : '' ?>> Year :</option>
<?php
for ($i=date('Y'); $i >= 1980 ; $i--) {
$selected = '' ;
if($pickYear == $i ) $selected = ' selected="selected"' ;
print('<option value="'.$i.'"'.$selected.'>'.$i.'</option>'."\n");
// echo $i.'<br/>';
}
?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment