흑흑.. 오늘은 셤 2과목입니다.
공부 하나도 못하고 있어요..
이리저리 불려다니느라... 게다가 이것까지...
하지만.. 열심히 답변해 드리죠.. ^^
<% if mode="ok" then %>
<%
search_title=request("search_title")
search_content=request("search_content")
search_name=request("search_name")
search_list=request("search")
%>
------------------------------------------------------
위의 내용은 검색에 관한거군요..
이전페이지에서 request 로 넘겨받는거에요..
제목,내용,이름 선택값..과 검색단어....
넘겨받는 것뿐입니다.
------------------------------------------------------
function reply()
{
document.reply.submit();
}
//-->
</script>
이건 답변을 달고자 할때 쓰이는 스크립트..
<%
id = request("id")
Set db = Server.CreateObject("ADODB.Connection")
db.Open dbname
db 파일에 연결하는 부분입니다.
UpdateSQL = "Update " & session("table") & " Set visit
= visit+1 where id = " & id
글 읽기를 할때 조회수를 올려주기 위한 겁니다.
글의 번호에만 조회수 1을 올려라 이거죠..
db.Execute UpdateSQL
이건.. 위의 조회수 올리는 문을 실행하라..
SQL = "SELECT
id,name,email,url,title,content,pin,writeday,tag,num,visit,re,res
ame,reid from " & session("table")
SQL = SQL & " where id = " & id
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL,db
%>
이건 글번호가 같은 걸 db파일에서 요청한..
id,name,email.. 등등 값을 가져오라...
--------------------------------------------------------------
<% if Rs.BOF or Rs.EOF then %>
<p>저장된 정보가 없어여.. </p>
<%
else
id = rs("id")
name = rs("name")
email = rs("email")
url = CheckWord(rs("url"))
title = rs("title")
content = rs("content")
pin = CheckWord(rs("pin"))
writeday = rs("writeday")
visit = rs("visit")
tag = rs("tag")
re = rs("re")
reid = rs("reid")
resame = rs("resame")
여기까지는 db파일에서 가져온 값들을 각 변수에 저장하는거에요.
if tag = "ok" then
title = CheckWord(title)
content = CheckWord(content)
else
title = replace(title,""","'")
content = replace(content,""","'")
end if
태그사용시 와 사용하지 않을때 html 적용에 관한거..
if search_title = 1 then
title = replace(title,search_list,"<b><font
color=#ff7b00>"&search_list&"</font></b>")
end if
if search_content = 1 then
content = replace(content,search_list,"<b><font
color=#ff7b00>"&search_list&"</font></b>")
end if
if search_name = 1 then
name = replace(name,search_list,"<b><font
color=#ff7b00>"&search_list&"</font></b>")
end if
위의 3개의 if 문은 검색한후 글읽기시...
검색단어를 구별해주기위해 색을 넣는거죠..
%>
--------------------------------------------------------
<%
rs.Close
SQL = "SELECT (id) FROM " & session("table")
SQL = SQL & " where reid = 0 and re > " & re
set rs = db.Execute(SQL)
if not (rs.BOF or rs.EOF) then
content_back = rs(0)
end if
rs.Close
SQL = "SELECT Max(id) FROM " & session("table")
SQL = SQL & " where reid = 0 and re < " & re
set rs = db.Execute(SQL)
if not (rs.BOF or rs.EOF) then
content_next = rs(0)
end if
rs.Close
SQL2 = "SELECT * FROM " & session("table")
SQL2 = SQL2 & " where re = " & re
if content_back <> "" then
SQL2 = SQL2 & " or id =" & content_back
end if
if content_next <> "" then
SQL2 = SQL2 & " or id =" & content_next
end if
SQL2 = SQL2 & " order by re desc,reid asc"
rs.Open SQL2,db
%>
------------------------------------------------------------
이건.. 그 현재의 글의 답변과 이전글과 다음글을 나타내기 위한
부분입니다.
<%
Do until Rs.EOF
name = rs("name")
writeday = left(rs("writeday"),8)
title = rs("title")
tag = rs("tag")
if left(now,2) = "20" then
nowday = mid(now,3)
else
nowday = now
end if
if tag = "ok" then
title = CheckWord(title)
If Len(title) > 30 Then
title = Mid(title,1,31) & ".."
End If
else
title = replace(title,""","'")
If Len(title) > 20 Then
title = Mid(title,1,21) & ".."
End If
end if
If Len(name) > 5 Then
name = Mid(name,1,6) & ".."
End If
If Len(title) > 24 Then
title = Mid(title,1,25) & "..."
End If
%>
----------------------------------------------------------
이건 위에 설명한것과 비슷하니.. 대충 아시겠죠??
이상입니다... ^^
곧 셤 시간이 다가와서.. 셤공부를 조금이라도 하기위해..
급하게 적었습니다... 헉헉~~~
이렇게 한꺼번에 하면.. 제가 설명을 붙이기 그러니..
담에 또 원하시는거 있으시면.. 조금씩.. 질문하세요..
그럼 거기에 관해 지금 보다는 좀더 자세히 적을 수 있을테니깐요..
그럼..항상 즐거운 시간 보내세요.. ^^
|