PHP - ³âµµ¸¦ Ç¥½ÃÇØ ÁÖ´Â ¼¿·ºÆ®¹Ú½º(SELECT BOX) |
|
|
![](icon/private_name/1.gif) |
13³â Àü |
PHP - ³âµµ¸¦ Ç¥½ÃÇØ ÁÖ´Â ¼¿·ºÆ®¹Ú½º(SELECT BOX)
¿ÃÇظ¦ ±âÁØÀ¸·Î yearRange ¸¸ÅÀÇ ³âµµ¸¦ Ç¥½ÃÇØ ÁÖ´Â ¼¿·ºÆ® ¹Ú½º·Î ¼³¸íº¸´Ù´Â Çѹø ½ÇÇàÇØ º¸½Ã´Â °ÍÀÌ ÀÌÇØÇϱ⠽±½À´Ï´Ù.
<?php
// º¸¿©Áú ³âµµÀÇ ¹üÀ§ - ÇöÀç³âºÎÅÍ 100³âÀü±îÁö Ç¥½ÃµË´Ï´Ù.
$yearRange = 100;
// ¼±ÅõǾîÁú ³âµµ - ÇöÀç³â ±âÁØ 20³âÀüÀÇ ³âµµ°¡ ¼±ÅõǾîÁý´Ï´Ù.
$ageLimit = 20;
$currentYear = date('Y');
$startYear = ($currentYear - $yearRange);
$selectYear = ($currentYear - $ageLimit);
echo '<select name="year">';
foreach (range($currentYear, $startYear) as $year) {
$selected = "";
if($year == $selectYear) { $selected = " selected"; }
echo '<option' . $selected . '>' . $year . '</option>';
}
echo '</select>';
?>
|
|
̵̧ : 577 |
̵̧
¸ñ·Ï
|
|