<script>
function chkSearch() {
if (document.all.shierzhi.value.split(" ").join("") == "")
{ alert("년도를 입력해주세요");
return false;
}
}
</script>
<table align="center" width="50%">
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" onSubmit="return chkSearch();">
<tr>
<td align="right" width="40%">
조회년도
</td>
<td align="left">
<input type="text" name="shierzhi" value="<?=$shierzhi;?>" size=20 style="background-color:ghostwhite; border:1px solid lightslategray;"> (예. 2023)
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" class="Box2" value=" ○ 조 회 하 기 ○ ">
</td>
</tr>
<tr>
<td colspan="2" align="center" class="Box6">
<?php
if($shierzhi) {
if(preg_match("/([^[:digit:]]+)/",$shierzhi)){
echo "<script>alert('숫자만 입력하세요.');location.href = \"".$_SERVER['PHP_SELF']."\";</script>";
exit;
}
$xx = ($shierzhi % 12);
$temp_arr = array("원숭이", "닭", "개", "돼지", "쥐", "소", "호랑이", "토끼", "용", "뱀", "말", "양");
$zz = ($shierzhi % 10);
$temp_arr2 = array("경", "신", "임", "계", "갑", "을", "병", "정", "무", "기");
$temp_arr3 = array("신", "유", "술", "해", "자", "축", "인", "묘", "진", "사", "오", "미");
$temp_arr4 = array("庚", "辛", "壬", "癸", "甲", "乙", "丙", "丁", "戊", "己");
$temp_arr5 = array("申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未");
echo $shierzhi."년도 ".$temp_arr2[$zz].$temp_arr3[$xx]."년(".$temp_arr4[$zz].$temp_arr5[$xx]."年) 십이지(十二辰)신은 <b>".$temp_arr[$xx]."</b>입니다.\r\n";
}
?>
</td>
</tr>
</form>
</table>