+++ ȨÁ¦ÀÛ ¹ÙÀ̺í +++
ȨÁ¦ÀÛ ¹ÙÀ̺í ÀÌ »çÀÌÆ®´Â ÀÌ¿µÂù´ÔÀÇ »çÀÌÆ®¸¦ º¹¿øÇÑ °ÍÀÔ´Ï´Ù.
Untitled Document
Html
Dhtml
Css
Php
Asp
Cgi
Java Script
Java Applet
Multimedia
Win Tip
°Ô½ÃÆǸ¸µé±â (6) - ±Ûµî·Ï½Ã°£
[³¯Â¥ Ãß°¡Çϱâ]

±ÛÀÇ µî·Ï ³¯Â¥¸¦ ¸®½ºÆ® È­¸é¿¡ º¸¿©ÁÖµµ·Ï ÇÏÀÚ. °¢°¢ÀÇ ±ÛÀ» ¿Ã¸± ¶§¸¶´Ù ¿Ã¸° ½Ã°£À» üũÇؼ­ DB¿¡ ÀúÀåÇØ¾ß ÇϹǷΠDB¿¡ ´ÙÀ½ ±×¸²Ã³·³ ±Û µî·Ï ½Ã°£À» ÀúÀåÇÒ °ø°£À» Ãß°¡ÇÑ´Ù. µ¥ÀÌÅÍÇü½ÄÀº ³¯Â¥/½Ã°£À¸·Î ¸ÂÃá´Ù.



±Ûµî·Ï½Ã°£Àº »ç¿ëÀÚ°¡ ÀÔ·ÂÆû¿¡ Á¤º¸¸¦ ÀÔ·ÂÇÏ°í Àü¼Û¹öÆ°À» ´­·¯¼­ DB¿¡ ÀÔ·ÂµÈ Á¤º¸¸¦ ¾÷µ¥ÀÌÆ® ½Ãų¶§ÀÇ ½Ã°£À» Àâ¾Æ¼­ DB¿¡ µî·ÏÇÑ´Ù. µû¶ó¼­ write.asp ¹®¼­´Â ¼Õ´îÇÊ¿ä¾ø°í, ½ÇÁ¦·Î ÀÚ·á¾÷½ÃÅ°´Â ¹®¼­ insert.asp ¹®¼­¸¸ ¼öÁ¤ÇÏ°í µî·ÏµÈ ½Ã°£À» ¸®½ºÆ® ¸ðµå¿¡¼­ º¸¿©ÁÖ¸é µÈ´Ù. ¸ÕÀú insert.asp ¹®¼­¸¦ ´ÙÀ½°ú °°ÀÌ ¼öÁ¤ÇÑ´Ù. ³ì»öºÎºÐÀÌ Ãß°¡µÈ ºÎºÐÀÌ´Ù.

<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library" FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"  -->
<%
Option Explicit

Dim name, title, comment, email,home
name = Request.form("name")
title = Request.form("title")
email = Request.form("email")
home = Request.form("home")
comment = Request.form("comment")

Dim strConnect,objRS
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\board.mdb"
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open "Myboard", strConnect, adOpenStatic, adLockPessimistic,adCmdTable

with objRS
.AddNew
.Fields("b_name") = name
.Fields("b_title") = title
.Fields("b_comment") = comment
      .Fields("b_ip") = Request.ServerVariables("REMOTE_ADDR")
      .Fields("b_email") = email
.Fields("b_home") = home
      .Fields("b_date") = now()
.Update
.Close
end with
Set objRS = nothing
Response.Write "insert ok"
%>


±× ´ÙÀ½Àº list.asp ¹®¼­¸¦ ´ÙÀ½°ú °°ÀÌ ¼öÁ¤Çؼ­ ±Û ¿Ã¸° ½Ã°£À» º¸¿©Áöµµ·Ï Çغ¸ÀÚ. ³ì»öºÎºÐÀÌ Ãß°¡µÈ ºÎºÐÀÌ´Ù.

<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library"
      FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"
-->
<%
Option Explicit
Dim strConnect
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\board.mdb"
Dim objConn,SQL,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard"
Set objRS = objConn.Execute(SQL)

Response.Write "<table border=1 width=500>" & _
               "<tr>" & _
               "<td align=center>À̸§</td>" & _
               "<td align=center>Á¦¸ñ</td>" & _
               "<td align=center>³¯Â¥</td>" & _
               "</tr>"

Do while Not objRS.EOF
    Response.Write "<tr>" &_
    "<td align=center><a href=mailto:" & objRS("b_email") & ">" & _
    objRS("b_name") & "</a></td>" & _
    "<td align=center><a href=./read.asp?key=" & _
    objRS("b_key") & ">" & objRS("b_title") & "</a></td>" & _
    "<td align=center>" & objRS("b_date") & "</td>" & _
    "</tr>"
    objRS.MoveNext
Loop

Response.Write "</table>"
Set objRS = nothing
Set objConn = nothing
%>


¼öÁ¤ÀÌ ³¡³µÀ¸¸é write.asp ¹®¼­¸¦ ºê¶ó¿ìÀú·Î ·ÎµùÇÑÈÄ ±ÛÇϳª¸¦ ³²±ä´Ù. ±×¸®°í list.asp ¹®¼­¸¦ º¸¸é ´ÙÀ½°ú °°À½À» È®ÀÎÇÒ ¼ö ÀÖ´Ù.



¹æ±Ý ¾´ ±Û¿¡¸¸ ³¯Â¥Á¤º¸°¡ ÀÖ°í ÀÌÀü¿¡´Â ¾Æ¹«·± °ªµµ ¾øÀ¸¹Ç·Î ±×¸²Ã³·³ ¾Æ¹«°Íµµ ³ª¿ÀÁö ¾Ê´Â´Ù. ±×¸®°í º¸½Ã´Ù½ÃÇÇ ±Û¾´½Ã°£ÀÌ ´ÊÀ»¼ö·Ï ¾Æ·¡¿¡ ³ª¿Â´Ù´Â°ÍÀ» ¾Ë¼ö ÀÖ´Ù.

º¸Åë °Ô½ÃÆÇÀº °¡Àå ÃÖ±Ù¿¡ ¾´±ÛÀÌ °¡Àå À§¿¡ ³ª¿À°ÔÇÏ´Â°Ô º¸ÅëÀ̴ϱñ ¿©±â¼­ list.aps ¹®¼­¸¦ ¾à°£ ¼öÁ¤ÇÏ¿© ÃÖ±Ù¿¡ ¾´±ÛÀÌ °¡Àå ¸ÕÀú ³ª¿Àµµ·Ï Çغ¸ÀÚ. ±×¸®°í list.asp ¹®¼­¿¡¼­ ±Û¾²±â¹®¼­ write.asp¹®¼­¸¦ ¸µÅ©½ÃÄѺ¸´Ù. ´ÙÀ½°ú °°ÀÌ list.asp ¹®¼­¸¦ ¼öÁ¤Çغ¸ÀÚ. ³ì»öºÎºÐÀÌ ¼öÁ¤µÇ°Å³ª Ãß°¡µÈ ºÎºÐÀÌ´Ù.

<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library"
      FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"
-->
<%
Option Explicit
Dim strConnect
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\board.mdb"
Dim objConn,SQL,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard order by b_key desc"
Set objRS = objConn.Execute(SQL)

Response.Write "<table border=1 width=500>" & _
               "<tr>" & _
               "<td align=center>À̸§</td>" & _
               "<td align=center>Á¦¸ñ</td>" & _
               "<td align=center>³¯Â¥</td>" & _
               "</tr>"

Do while Not objRS.EOF
    Response.Write "<tr>" &_
    "<td align=center><a href=mailto:" & _
    objRS("b_email") & ">" & objRS("b_name") & "</a></td>" & _
    "<td align=center><a href=./read.asp?key=" & _
    objRS("b_key") & ">" & objRS("b_title") & "</a></td>" & _
    "<td align=center>" & objRS("b_date") & "</td>" & _
    "</tr>"
    objRS.MoveNext
Loop

Response.Write "</table>"
Response.Write "<table border=0 width=500>" & _
               "<tr><td align=right><a href=write.asp>±Û¾²±â</a></td></tr>" & _
               "</table>"


Set objRS = nothing
Set objConn = nothing
%>


´ÙÀ½Àº ¼öÁ¤ÈÄ list.asp ¹®¼­ÀÇ Ãâ·Â °á°úÀÌ´Ù. ¿ì¸®°¡ ¿øÇÏ´ø ´ë·Î ÃÖ±Ù¿¡ ¾´±ÛÀÌ »ó´Ü¿¡ À§Ä¡ÇÏ°í ÀÖ´Ù.



±×·±µ¥ ¿©±â¼­ ³¯Â¥ ºÎºÐÀÇ Ãâ·ÂÀÌ ³Ê¹« ±æ´Ù. ÀÌ ºÎºÐÀ» ³»°¡ ¿øÇÏ´Â Çü½ÄÀÇ ³¯Â¥Å¸ÀÔÀ¸·Î ¹Ù²Ù¾î º¸ÀÚ. ¿¹¸¦ µé¾î 2001/05/30 À̶óµçÁö 2001:05:30 (16:40) ÀÇ Çü½ÄÀ¸¶óµçÁö ¶Ç´Â ¿ù°ú Àϸ¸ ³ª¿Àµµ·Ï ÇÏ´Â ¹æ¹ýÀ» ¾Ë¾Æº¸ÀÚ.

list.asp ¹®¼­¿¡¼­ ³¯Â¥¸¦ ¾ò´Â ¹æ¹ýÀº ·¹ÄÚµå¼ÂÀÇ ÀνºÅϽº°ªÀ» °¡Áø º¯¼ö objRS ¿¡ objRS("b_date") ÇÏ¸é ±× °á°ú¸¦ ¾òÀ» ¼ö ÀÖ´Ù ÀÌ°ÍÀ» ÀÌ¿ëÇÏ¸é ¾ò¾îÁö´Â °á°ú´Â À§ÀÇ ±×¸²¿¡¼­¿Í °°ÀÌ 2001-05-13 ¿ÀÈÄ 4:04:57ÀÇ Çü½ÄÀ¸·Î ¾ò¾îÁö¹Ç·Î ¿ì¸° ÀÌ°ÍÀ» ½ºÆ®¸µ ÆíÁýÀ» ÅëÇØ ¿øÇÏ´Â ´ë·ÎÀÇ ½Ã°£Çü½ÄÀ» ¾ò¾î ³¾ ¼ö ÀÖ´Ù. ¸ÕÀú »õ·Î¿î º¯¼ö¸¦ yymmdd¶ó´Â º¯¼ö¸¦ »ý¼ºÇÑ´Ù. ±×¸®°í ÀÌ º¯¼ö¿¡ ¿ì¸®°¡ DB¿¡¼­ ¾òÀº ½Ã°£À» ´ëÀÔÇÑ´Ù.

Dim vDate,vYear,vMonth,vDay,vHour,vMin
vDate = objRS("b_date")
vYear = year(vDate)
vMonth = month(vDate)
vDay = day(vDate)
vHour = hour(vDate)
vMin = minute(vDate)

ÀÌ·¸°Ô ÇÏ¸é °¢°¢ÀÇ ³â,¿ù,ÀÏ,½Ã,ºÐÀ» »õ·Î¿î º¯¼ö¿¡¼­ ¾òÀ» ¼ö ÀÖ´Ù. year(vDate) ´Â vDate °¡ °¡Áö°í ÀÖ´Â ºÎºÐ¿¡¼­ ¿¬µµ¿¡ ÇØ´çÇÏ´Â ºÎºÐ¸¸ ¸®ÅϽÃŲ´Ù. ´Ù¸¥ ºÎºÐµµ ¸¶Âù°¡ÁöÀÌ´Ù. ±×·±µ¥ ¿¬µµÀÇ °æ¿ì´Â 2001³â ½ÄÀ¸·Î Ç×»ó 4ÀÚ¸®ÀÇ ¼ö¸¦ °¡Áö°í ÀÖ´Â ¹Ý¸é ´ÞÀÇ °æ¿ì´Â 12¿ù 11¿ù 10¿ùÀº µÎÀÚ¸® ÀÌÁö¸¸ 1¿ùºÎÅÍ 9¿ùÀº ÇÑÀÚ¸®¸¸ ¸®ÅϵȴÙ. ÀÌ·² °æ¿ì ¸®½ºÆ® È­¸é¿¡ ±×³É »Ñ·ÁÁÖ¸é ÀÚ¸®¼ö°¡ Â÷ÀÌ°¡ ³ª´Â °æ¿ì ¸®½ºÆ®È­¸éÀÌ º¼»ó ½º·¯¿öÁø´Ù. µû¶ó¼­ ÀÚ¸®¼ö¸¦ °°°Ô ÇÑ´Ù.

month(vDate) ÇÏ¸é ¸®ÅϵǴ °ÍÀº 1-12ÀÇ ¼ö°¡ ¸®ÅϵȴÙ. ¾î¶² ¼ö°¡ ¸®ÅϵǴø°£µ¥ ¹«Á¶°Ç 0¸¦ ¾Õ¿¡ ºÙÀÌ°í µÚ¿¡¼­ºÎÅÍ µÎÀÚ¸®¸¸ Ãâ·Â½ÃŲ´Ù. ¿¹¸¦ µé¾î 12 °¡ ¸®ÅϵǸé 0¸¦ ¾Õ¿¡ ºÙÀ̸é 012 ÀÌ°ÍÀ» µÚ¿¡¼­ 2ÀÚ¸®¸¸ Ãâ·Â½ÃÅ°¸é 12 °¡ µÈ´Ù. ¶Ç  1 ÀÌ ¸®ÅÏµÇ¸é ¾Õ¿¡ 0À» ºÙÀÌ°í 01 ¿ª½Ã µÚ¿¡¼­ µÎÀÚ¸¸ ¸®ÅϽÃÅ°¸é 01ÀÇ °ªÀ» ¾òÀ» ¼ö ÀÖ´Ù. ÀÌ°ÍÀº right ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù. day ¿ª½Ã ¸¶Âù°¡Áö·Î 1-31 ±îÁöÀÇ ¼ö°¡ ¸®ÅÏ °¡´ÉÇϹǷΠ¿ª½Ã ÀÚ¸®¼ö¸¦ ¸ÂÃß¾î ÁØ´Ù. ½Ã°£ ¿ª½Ã 0¿¡¼­ 23±îÁö ¸®ÅÏ µÇ¹Ç·Î ÀÚ¸®¼ö¸¦ 맟Ãß°í ºÐ ¿ª½Ã 0ºÐ¿¡¼­ 59±îÁö ¸®ÅϵǹǷΠ¿ª½Ã °°Àº ¹æ½ÄÀ¸·Î ÀÚ¸®¼ö¸¦ ¸ÂÃá´Ù.

vYear = year(vDate)
vMonth = right("0" & month(vDate) , 2)
vDay = right("0" & day(vDate), 2)
vHour = right("0" & hour(vDate),2)
vMin = right("0" & minute(vDate),2)

ÇÏÁö¸¸ ÃÖÁ¾ÀûÀ¸·Î Ãâ·ÂÇÏ´Â ºÎºÐÀº ³¯Â¥ ºÎºÐÀ̹ǷΠÀÌ°ÍÀ» Á¶ÇÕÇؼ­

vDate =  vYear & "/" & vMonth & "/" & vDay & " (" & vHour & ":" & vMin & ")"

ÀÇ Çü½ÄÀ¸·Î ¸¸µé¾î ÁÖ¸é µÈ´Ù. À̺κÐÀº ³¯Â¥°¡ Ãâ·ÂµÇ´Â list.asp ¹®¼­¿¡¼­ ÇØÁÖ¾î¾ß ÇÑ´Ù. ÀÚ ¶Ç ¼öÁ¤ÇÏÀÚ list.aps ¹®¼­¸¦ ´ÙÀ½°ú °°ÀÌ ¼öÁ¤Çغ»´Ù.

<!--METADATA TYPE= "typelib"  NAME= "ADODB Type Library"
      FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll"
-->
<%
Option Explicit
Dim strConnect
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\DataStore\board.mdb"
Dim objConn,SQL,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
SQL = "select * from MyBoard order by b_key desc"
Set objRS = objConn.Execute(SQL)

Response.Write "<table border=1 width=500>" & _
               "<tr>" & _
               "<td align=center>À̸§</td>" & _
               "<td align=center>Á¦¸ñ</td>" & _
               "<td align=center>³¯Â¥</td>" & _
               "</tr>"

Dim vDate,vYear,vMonth,vDay,vHour,vMin

Do while Not objRS.EOF
    vDate = objRS("b_date")
    vYear = year(vDate)
    vMonth = right("0" & month(vDate) , 2)
    vDay = right("0" & day(vDate), 2)
    vHour = right("0" & hour(vDate),2)
    vMin = right("0" & minute(vDate),2)
    vDate =  vYear & "/" & vMonth & "/" & vDay & " (" & vHour & ":" & vMin & ")"


    Response.Write "<tr>" &_
    "<td align=center><a href=mailto:" & objRS("b_email") & ">" & objRS("b_name") & "</a></td>" & _
    "<td align=center><a href=./read.asp?key=" & _
    objRS("b_key") & ">" & objRS("b_title") & "</a></td>" & _
    "<td align=center>" & vDate & "</td>" & _
    "</tr>"
    objRS.MoveNext
Loop

Response.Write "</table>"
Response.Write "<table border=0 width=500>" & _
               "<tr><td align=right><a href=write.asp>±Û¾²±â</a></td></tr>" & _
               "</table>"

Set objRS = nothing
Set objConn = nothing
%>


´ÙÀ½Àº ¼öÁ¤ÈÄ È­¸éÀÌ´Ù. ½Ã°£ ºÎºÐÀÌ ¸ÚÁö°Ô ¹Ù²î¾ú´Ù.



Update : 2001/05/29 [µ¹¾Æ°¡±â]