사이트 내 전체검색
PHP
[PHP] 우편번호 php문서에 삽입하기 (2007/12/15 수정)
로빈아빠
https://cmd.kr/php/617 URL이 복사되었습니다.

본문

write.php 에서의 우편번호 부분

<form name="WriteForm">
  <input name="zip1" type="text" size="4"  readonly>-
  <input name="zip2" type="text" size="4" readonly>
  <a href="#" onClick="window.open('ZipCode.php','zip','width=471, height=472, left=50,top=50, location=no, scrollbars=yes, menubar=no, resizable=no, status=no, toolbar=no');"><img src="./images/address_post.gif" width="76" height="20" border="0" align="absmiddle" style="cursor:pointer"></a><br>
  <input name="address1" type="text" style="width:98%" readonly><br>
  <input name="address2" type="text" style="width:98%">
</form>




ZipCode.php

<?
  $mysql_host = "localhost";
  $mysql_user = "아이디";
  $mysql_password = "비밀번호";
  $mysql_db = "디비네임";
  $dbconn = mysql_connect("$mysql_host","$mysql_user","$mysql_password") or die("데이터베이스 연결에 실패하였습니다.");
  mysql_select_db($mysql_db, $dbconn);
 ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>우편번호 검색</title>
</head>

<body>
<table width="447" border="0" cellpadding="0" cellspacing="10" bgcolor="#043CAB">
  <tr>
    <td valign="top" bgcolor="#FFFFFF" style="padding:10 10 10 10;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="./images/adress_title.gif" width="411" height="43"></td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td style="letter-spacing:-1px;">검색을 원하시는 주소지를 동/읍/면 단위로 입력한 다음, <font color="#ED0063"><strong>찾기 버튼</strong></font>을 누르세요.<br>
          (예 : 서초동 → 서초,  부안읍 → 부안,  수내면 → 수내 )</td>
      </tr>
      <tr>
        <td height="17"> </td>
      </tr>
      <tr>
        <td align="center">
          <form action="<?=$PHP_SELF?>">
            <strong>읍/면/동</strong>
            <input name="s" type="text" class="hp_input3" size="30">
            <input type="image" src="./images/address_search.gif" align="absmiddle">
          </form>
          <script>
            <!--
            function copy(a, b, c) {
              opener.WriteForm.zip1.value = a;
              opener.WriteForm.zip2.value = b;
              opener.WriteForm.address1.value = c;
              opener.WriteForm.address2.focus();
              window.close();
            }
            //-->
          </script>
        </td>
      </tr>
      <tr>
        <td height="19"> </td>
      </tr>
      <tr>
        <td><img src="./images/adress_default.gif" width="104" height="20"></td>
      </tr>
      <tr>
        <td height="8"></td>
      </tr>
      <tr>
        <td><table width="100%" height="227" border="0" cellpadding="10" cellspacing="1" bgcolor="#F2006A">
          <tr>
            <td valign="top" bgcolor="#FFFFFF"><?
              if($s) {
                $query = "select * from 우편번호테이블 where (gugun like '%$s%') or (dong like '%$s%')  ";
                $result = mysql_query($query, $dbconn);
                while($data = mysql_fetch_array($result))  {
                  $tmp = explode("-",$data[zipcode]);
                  $a = $tmp[0];
                  $b = $tmp[1];
            ?>
              <a href="#" onClick="copy('<?=$a?>','<?=$b?>','<?=$data[sido]?> <?=$data[gugun]?> <?=$data[dong]?> <?=$data[ri]?>')">
              [<?=$a?>-<?=$b?>] <?=$data[sido]?> <?=$data[gugun]?> <?=$data[dong]?> <?=$data[ri]?> <?=$data[bunji]?></a><br>
            <?
                }
              }
              else {
                echo "검색하지 않았거나, 검색결과가 없습니다.";
              }
            ?></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

댓글목록

등록된 댓글이 없습니다.

PHP
871 (8/18P)

Search

Copyright © Cmd 명령어 3.146.255.87