(3)글 목록 화면 리스트 만들기 소스 list.asp<?XML:NAMESPACE PREFIX = O />
<%@ Language=VBScript %>
<html>
<head>
<meta HTTP-EQUIV="refresh" CONTENT="text/html; charset=euc-kr">
<title>방명록</title>
<!--#include file="../dbconn.inc" -->
<link rel="stylesheet" type="text/css" href="../boardStyle.css">
</head>
<%
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adUseClient = 3
' 디비에서 레코드를 불러오는 부분입니다. 정렬기준은 등록일 내림차순입니다.
set rs=server.CreateObject("ADODB.RecordSet")
strSQL="select * from dbo_tbl_guestbook order by writedate desc"
rs.CursorLocation=adUseClient
rs.open strSQL,conn,adOpenStatic,adLockReadOnly
%>
<body bgcolor="#C0C0B0" text="#000000" leftmargin="30">
<%
if rs.EOF then ' 디비에 등록된 레코드가 없을때의 처리
%>
<p align="center"> 아직 등록된 자료가 없습니다
<br>
<a href="frm_write.asp">write</a>
</p>
<br>
<% else %>
<%
r_count=rs.RecordCount ' 레코드의 총갯수
rs.PageSize=10 ' 한페이지에 뿌려질 레코드의 수
conternp=10 ' 레코드수가 많을때 한번에 스킵 할 수 있는 페이지 단위입니다.
page=Request.QueryString("page") ' 현재 페이지를 알아내는 부분입니다.
if page <> "" Then
curPage = page
if curPage < 1 Then
curPage = 1
end if
else
curPage=1
end if
RS.AbsolutePage = curPage
totPage = r_count \ rs.PageSize ' 총페이지를 구한다.
if not totPage*rs.PageSize = r_count then totPage=totPage+1
%>
<p align="center"><b><font face="arial" size="4">guestbook</b></font> </p>
<table border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="WIDTH: 600px">
<tr>
<td><b>전체 등록 글 수 :</font> <font size="2" face= "굴림"color="blue"><%=r_count%></font> 개 </b></td>
<tdalign="right"><small><%=CurPage%> / <%=totPage%></small></td>
</table>
<%
i=0
do while not rs.EOF and rs.PageSize > i
content=replace(rs("content"),vbCrLf,"<br>") ' 자동 줄개행을 위해서..
%>
<table align="center" border="0" width="600" cellpadding="0" cellspacing="0" bordercolor=#313118>
<tr height="25">
<td width=70 style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> 작성자</td>
<td width=100 style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> <%=rs("writer")%> </td>
<td width=100 style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> 전자우편 </td>< BR> <td width=100style="BACKGROUND-COLOR:#C0C0B0;COLOR:#313118"> <ahref="mailto:<%=rs("email")%>"><%=rs("email")%></a> </td>
<td width=70 style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> 등록일 </td>
<td width=160 style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> <%=rs("writedate")%> </td>
</tr><tr height="25">
<td style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> IP </td>
<td style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> <%=rs("ip")%> </td>
<td style="BACKGROUND-COLOR: #C0C0B0; COLOR: #313118"> 홈페이지 </td>
<td colspan=2 style= "BACKGROUND-COLOR: #C0C0B0;COLOR:#313118"> <ahref= "<%= rs("homepage")%>"target="_blank"><%= rs("homepage")%></a> </td><BR><tdalign=rightstyle="BACKGROUND-COLOR:#C0C0B0;COLOR:#313118">
' 수정또는 삭제시 일단비밀번호를 검사하기위해 passwdCheck페이지로이동합니다.
[<ahref="passwdCheck.asp?no=<%=rs("pk_id")%>&job=del">삭제</a>]
[<ahref="passwdCheck.asp?no=<%=rs("pk_id")%>&job=edit">수정</a>] </td>
</tr><tr>
<td colspan="6" style="BORDER-BOTTOM: 1px dashed; BORDER-LEFT: 1px dashed; BORDER-RIGHT: 1px dashed; BORDER-TOP: 1px dashed; PADDING-LEFT: 30px; PADDING-RIGHT: 30px; PADDING-TOP: 10px; PADDING-BOTTOM: 10px" >
<%= content >
</td></tr>
</tr><tr><td> </td></tr>
</table>
<%
i=i+1
rs.MoveNext ' 다음 레코드로 이동
loop
if Request.QueryString("startpage")="" then
startpage=1
else
startpage=Request.QueryString("startpage")
end if
%>
</table>
<p align="center">
<%if totpage>conternp then%> ' 일단 총페이지가 스킵하는 페이지 단위보다 크면..
<%if startpage=1 then%> ' 현페이지는 1이되고..
[ <font color="dimgray" size="2" face="굴림">이전 <%=conternp%>개 </font> ]
<%else%>
[<ahref="list.asp?forum_id=<%=forum_id%>&page=<%=cint(startpage)-conternp%>&startpage=<%=cint(startpage)-conternp%>" id="RED"> 이전 <%=conternp%> 개 </a>]
<%end if
' 이부분은 직접이동할수 있는 페이지를 화면에 순차적으로 뿌립니다..
For a=startpage to startpage+conternp-1
if a>totpage then
exit for
else
if a=curpage then%>
<%=a%>
<%else%>
<ahref="list.asp?forum_id=<%=forum_id%>&page=<%=a%>&startpage=<%= startpage%>"id="RED"><%=a%></a>
<%End if%>
<%end if%>
<%Next%>
<%if((startpage\conternp)=(totpage\conternp)) then%> ' 직접 스킵할수있는 페이지수가 없다면
[ <font color="dimgray" size="2" face="굴림">다음 <%=conternp%>개</font> ]
<%else%>
[<ahref="list.asp?forum_id=<%=forum_id%>&page=<%=a%>&startpage=<%=a%>" id="RED"> 다음 <%=conternp%>개 </a>]
<%end if%>
<%else%>
[ <font color="#808000" size="2" face="굴림">이전 <%=conternp%>개 </font> ]
<%
For a=startpage to totpage
if a=curpage then%>
<%=a%>
<%else%>
<ahref="list.asp?forum_id=<%=forum_id%>&page=<%=a%>"><%=a%></a>
<% end if
next%>
[ <font color="#808000" size="2" face="굴림">다음 <%=conternp%>개 </font> ]
<%end if%>
<br>
<% if curPage > 1 Then %> ' 현재페이지가 첫페이지보다 크다면..
[ <ahref="list.asp?page=<%=curPage-1%>&Forum_id=<%=Forum_id%>"> 전 리스트 </a>
<% else %>[ 전 리스트
<% end if %>
<BR>| <ahref="frm_write.asp?Forum_id=<%=Forum_id%>"> 글올리기 </a> |
<% if i=rs.PageSize Then %> ' 요 i는 화면에 뿌려진 레코드의 수 입니다.
<ahref="list.asp?page=<%=curPage+1%>&Forum_id=<%=Forum_id%>"> 다음 리스트 </a>]
<% else %> 다음 리스트 ]
<% end if %>
</p>
</table>
<% end if %>
<div align="center">
<hr align="center" width="400" color="black">
</div>
<div align="center">
copyright ⓒ 2000 webnics<sup>tm</sup> All rights reserved. </div>
<%
rs.close
set rs=nothing
%>
</body>
</html>
[출처] 정신차렷
"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기, 각종 광고, 영업, 판매, 제안서, 전단지 반응율 3배×10배 이상 높이는 마법의 8단계 공식" |
☞자세히보기 |
|
|