Oracle [ClassASP] 페이징(페이지 목록/리스트)
페이지 정보
본문
1. list.asp 내용
<!--#include virtual="function.asp"-->
<html>
<head>
</head>
<body>
<%
intTCnt = 0 ' 전체 게시물수
intPageCnt = 0 ' 전체 페이지수
intPageSize = 20 ' 한번에 보여줄 게시물수
intPageView = 10 ' 한번에 보여줄 페이지수
intPage = request("page")
If intPage = "" Then
intPage = 1
End If
strURL = "?idx=" & idx
SQL = " select count(*) as totCnt from aaa a INNER JOIN bbb b ON a.aIDX=b.IDX "
SQL = SQL & " Where a.aIDX = b.IDX and a.aIDX = " & idx
Set oRs = Conn.Execute(SQL)
intTCnt = CDbl(oRs("totCnt"))
oRs.close
'response.write intTCnt
'response.write strSql
If intTCnt > 0 Then
If (intTCnt Mod intPageSize) = 0 Then
intPageCnt = Int(intTCnt / intPageSize)
Else
intPageCnt = Int(intTCnt / intPageSize) + 1
End If
End If
startRow = (intPage - 1) * intPageSize + 1
endRow = startRow + intPageSize - 1
SQL = " SELECT * FROM "
SQL = SQL & " (select / *+index_desc(a aaa_PK)* / rownum rnum "
' order by 정렬 필요없을때
'SQL = SQL & " , a.*, b.bname from aaa a INNER JOIN bbb b ON a.aIDX=b.IDX "
' order by 정렬 필요할때
SQL = SQL & " , a.*, b.bname from "
SQL = SQL & " (select * from aaa order by send_date desc) a "
SQL = SQL & " INNER JOIN bbb b ON a.aIDX=b.IDX "
' order by 정렬 끝
SQL = SQL & " Where a.aIDX = b.IDX and a.aIDX = " & idx
SQL = SQL & " and rownum<=" &endRow& ") "
SQL = SQL & " where rnum>= " & startRow
'response.write SQL
Set Rs = Conn.Execute(SQL)
If rs.bof And rs.eof Then
response.write ""
Else
cnt = 0
Do Until rs.eof
cnt = cnt + 1
%>
반복내용
<%
rs.movenext
Loop
end if
%>
<%
' 페이징 호출
Call PageList(intPage, intPageCnt, intPageView, strURL)
%>
</body>
</html>
2. function.asp 내용
<%
' Paging Function 시작
Sub PageList(Page, PageCnt, PageNum, p_URL)
Dim s_Page
Dim iCnt, jCnt
Page = CInt(Page)
PageCnt = CInt(PageCnt)
PageNum = CInt(PageNum)
If Page Mod PageNum = 0 Then
s_Page = int(Page / PageNum) - 1
Else
s_Page = int(Page / PageNum)
End If
If PageCnt > 0 Then
If Page > 1 Then
Response.Write "<a href='" & p_URL & "&page=1'><img src=""/img/icon_first.gif"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_first.gif"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
If s_Page >= 1 Then
Response.Write "<a href='" & p_URL & "&page=" & ((s_Page - 1) * PageNum) + 1 & "'><img src=""/img/icon_prev.gif"" hspace=""3"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_prev.gif"" hspace=""3"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
iCnt = s_Page * PageNum + 1
jCnt = 1
For jCnt = iCnt To (iCnt + PageNum) - 1
If CStr(jCnt) = CStr(Page) Then
Response.Write "<b>" & jCnt & "</b>"
Else
Response.Write "<a href='" & p_URL & "&page=" & jCnt & "'>" & jCnt & "</a>"
End If
If jCnt = PageCnt Or jCnt = (iCnt + PageNum) - 1 Then
Exit For
Else
Response.Write " | "
End If
Next
response.write " "
If ((s_Page + 1 ) * PageNum) < PageCnt Then
Response.Write "<a href='" & p_URL & "&page=" & ((s_Page + 1) * PageNum) + 1 & "'><img src=""/img/icon_next.gif"" hspace=""3"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_next.gif"" hspace=""3"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
If Page < PageCnt Then
Response.Write "<a href='" & p_URL & "&page=" & PageCnt & "'><img src=""/img/icon_last.gif"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_last.gif"" border=""0"" align=""absmiddle"" />"
End If
Else
Response.Write " "
End If
End Sub
' Paging Function 끝
%>
참고자료
http://blog.naver.com/myheredity/130073111279
<!--#include virtual="function.asp"-->
<html>
<head>
</head>
<body>
<%
intTCnt = 0 ' 전체 게시물수
intPageCnt = 0 ' 전체 페이지수
intPageSize = 20 ' 한번에 보여줄 게시물수
intPageView = 10 ' 한번에 보여줄 페이지수
intPage = request("page")
If intPage = "" Then
intPage = 1
End If
strURL = "?idx=" & idx
SQL = " select count(*) as totCnt from aaa a INNER JOIN bbb b ON a.aIDX=b.IDX "
SQL = SQL & " Where a.aIDX = b.IDX and a.aIDX = " & idx
Set oRs = Conn.Execute(SQL)
intTCnt = CDbl(oRs("totCnt"))
oRs.close
'response.write intTCnt
'response.write strSql
If intTCnt > 0 Then
If (intTCnt Mod intPageSize) = 0 Then
intPageCnt = Int(intTCnt / intPageSize)
Else
intPageCnt = Int(intTCnt / intPageSize) + 1
End If
End If
startRow = (intPage - 1) * intPageSize + 1
endRow = startRow + intPageSize - 1
SQL = " SELECT * FROM "
SQL = SQL & " (select / *+index_desc(a aaa_PK)* / rownum rnum "
' order by 정렬 필요없을때
'SQL = SQL & " , a.*, b.bname from aaa a INNER JOIN bbb b ON a.aIDX=b.IDX "
' order by 정렬 필요할때
SQL = SQL & " , a.*, b.bname from "
SQL = SQL & " (select * from aaa order by send_date desc) a "
SQL = SQL & " INNER JOIN bbb b ON a.aIDX=b.IDX "
' order by 정렬 끝
SQL = SQL & " Where a.aIDX = b.IDX and a.aIDX = " & idx
SQL = SQL & " and rownum<=" &endRow& ") "
SQL = SQL & " where rnum>= " & startRow
'response.write SQL
Set Rs = Conn.Execute(SQL)
If rs.bof And rs.eof Then
response.write ""
Else
cnt = 0
Do Until rs.eof
cnt = cnt + 1
%>
반복내용
<%
rs.movenext
Loop
end if
%>
<%
' 페이징 호출
Call PageList(intPage, intPageCnt, intPageView, strURL)
%>
</body>
</html>
2. function.asp 내용
<%
' Paging Function 시작
Sub PageList(Page, PageCnt, PageNum, p_URL)
Dim s_Page
Dim iCnt, jCnt
Page = CInt(Page)
PageCnt = CInt(PageCnt)
PageNum = CInt(PageNum)
If Page Mod PageNum = 0 Then
s_Page = int(Page / PageNum) - 1
Else
s_Page = int(Page / PageNum)
End If
If PageCnt > 0 Then
If Page > 1 Then
Response.Write "<a href='" & p_URL & "&page=1'><img src=""/img/icon_first.gif"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_first.gif"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
If s_Page >= 1 Then
Response.Write "<a href='" & p_URL & "&page=" & ((s_Page - 1) * PageNum) + 1 & "'><img src=""/img/icon_prev.gif"" hspace=""3"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_prev.gif"" hspace=""3"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
iCnt = s_Page * PageNum + 1
jCnt = 1
For jCnt = iCnt To (iCnt + PageNum) - 1
If CStr(jCnt) = CStr(Page) Then
Response.Write "<b>" & jCnt & "</b>"
Else
Response.Write "<a href='" & p_URL & "&page=" & jCnt & "'>" & jCnt & "</a>"
End If
If jCnt = PageCnt Or jCnt = (iCnt + PageNum) - 1 Then
Exit For
Else
Response.Write " | "
End If
Next
response.write " "
If ((s_Page + 1 ) * PageNum) < PageCnt Then
Response.Write "<a href='" & p_URL & "&page=" & ((s_Page + 1) * PageNum) + 1 & "'><img src=""/img/icon_next.gif"" hspace=""3"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_next.gif"" hspace=""3"" border=""0"" align=""absmiddle"" />"
End If
response.write " "
If Page < PageCnt Then
Response.Write "<a href='" & p_URL & "&page=" & PageCnt & "'><img src=""/img/icon_last.gif"" border=""0"" align=""absmiddle"" /></a>"
Else
Response.Write "<img src=""/img/icon_last.gif"" border=""0"" align=""absmiddle"" />"
End If
Else
Response.Write " "
End If
End Sub
' Paging Function 끝
%>
참고자료
http://blog.naver.com/myheredity/130073111279
댓글목록
등록된 댓글이 없습니다.