Call GlobalDBConnection(objConn, strConnect)

 Dim Sql ,TotalRecord ,PageLength ,MoveSize ,FirstColumn ,LastColumn ,TotalPage ,FirstPage ,LastPage
 Sql = "SELECT COUNT(*)"
 Sql = Sql & " FROM SH_MANAGER_BBS S INNER JOIN SH_MASTERCODE E"
 Sql = Sql & " ON S.BBS_SEQ = E.CODE"
 Sql = Sql & " INNER JOIN SH_MAJORCODE D"
 Sql = Sql & " ON E.MAJORCODE = D.POTAL_MAJORCODE"
 Sql = Sql & " WHERE D.POTAL_MAJORCODE = 11"  Set rs = objConn.Execute(Sql)

 TotalRecord = Cint(rs(0))

 rs.Close
 Call GlobalDBClose(objConn)

'--------------- 한 페이지 글의 수와 한 페이지 페이징 수 설정
 PageLength = 10
 MoveSize = 10


'--------------- 디비에서 가져올 컬럼들의 범위 계산
 FirstColumn = (CurrentPage - 1) * PageLength + 1
 LastColumn = CurrentPage * PageLength

 If LastColumn > TotalRecord Then
  LastColumn = TotalRecord
 End If

'--------------- 전체 페이지 수 계산
 TotalPage = Int(TotalRecord / PageLength)

 If TotalRecord Mod PageLength > 0 Then
  TotalPage = TotalPage + 1
 End If

'--------------- 현재 화면에 보여줄 페이지들의 범위 계산
 FirstPage = Cint((CurrentPage - 0.8) \ MoveSize) * MoveSize + 1
 LastPage = FirstPage + MoveSize - 1

 If LastPage > TotalPage Then
  LastPage = TotalPage
 End If


 Sql = "SELECT RN ,BBS_SEQ ,SEQ ,SUBJECT ,USER_NAME ,REGDATE ,TOP_OR_NOT ,CODENAME FROM ("
 Sql = Sql & "  SELECT ROWNUM AS RN, X.* FROM ("
 Sql = Sql & "   SELECT S.BBS_SEQ ,S.SEQ ,S.SUBJECT ,S.USER_NAME ,S.REGDATE ,S.TOP_OR_NOT ,E.CODENAME"
 Sql = Sql & "   FROM SH_MANAGER_BBS S INNER JOIN SH_MASTERCODE E"
 Sql = Sql & "   ON S.BBS_SEQ = E.CODE"
 Sql = Sql & "   INNER JOIN SH_MAJORCODE D"
 Sql = Sql & "   ON E.MAJORCODE = D.POTAL_MAJORCODE"
 Sql = Sql & "   WHERE D.POTAL_MAJORCODE = 11"  Sql = Sql & "   ORDER BY S.REGDATE DESC"
 Sql = Sql & "   ) X"
 Sql = Sql & "  )"
 Sql = Sql & " WHERE RN >= '" & FirstColumn & "' And RN <= '" & LastColumn & "'"
 Sql = Sql & " ORDER BY RN ASC"


 Call GlobalDBConnection(objConn, strConnect)
 Set rs = Server.CreateObject("ADODB.RecordSet")
 rs.Open Sql, objConn, 1, 1



페이징 하는 부분....



<!-- paging start -->
<%
 If TotalRecord = 0 Then
%>
       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
        <td align="right"><a href="<%=RootDefault%>/Notice/Notice_List.asp"><img src="<%=showRootDefault%>/img/common/btn_list.gif" border="0"></a></td>
       </tr>
       </table>
<%
 Else
%>
       <div style="float:right"><a href="<%=RootDefault%>/Notice/Notice_List.asp"><img src="<%=showRootDefault%>/img/common/btn_list.gif" border="0"></a></div>

       <table cellpadding="0" cellspacing="0" border="0">
       <tr>
<%

'  Call TestShow("CurrentUrl", CurrentUrl)

  If FirstPage > 1 Then
%>
        <td><a href="<%=RootDefault%>/Notice/Notice_List.asp?page=<%=(FirstPage - MoveSize) & searchpage%>" class="paging"><img src="<%=showRootDefault%>/img/common/bts_prev.gif" style="cursor:hand" alt="이전 <%=MoveSize%>개"></td>
<%
  Else
%>
        <td><img src="<%=showRootDefault%>/img/common/bts_prev.gif" alt="이전 페이지가 없습니다."></td>
<%
  End If
%>
        <td width="10"></td>
<%
  For GoPage = FirstPage To LastPage
   If GoPage = CurrentPage Then

%>
        <td width="1"><img src="<%=showRootDefault%>/img/common/paging_bar.gif"></td>
        <td class="paging_num"><font class="page_on"><%=GoPage%></font></td><!-- now -->
<%
   Else
%>
        <td width="1"><img src="<%=showRootDefault%>/img/common/paging_bar.gif"></td>
        <td class="paging_num"><a href="<%=RootDefault%>/Notice/Notice_List.asp?page=<%=GoPage & searchpage%>" class="paging"><%=GoPage%></a></td>
<%
   End If
  Next
%>
        <td width="1"><img src="<%=showRootDefault%>/img/common/paging_bar.gif"></td>
        <td width="10"></td>
<%
  If LastPage < TotalPage Then
%>
        <td><a href="<%=RootDefault%>/Notice/Notice_List.asp?page=<%=(FirstPage + MoveSize) & searchpage%>" class="paging"><img src="<%=showRootDefault%>/img/common/bts_next.gif" style="cursor:hand" alt="다음 <%=MoveSize%>개"></td>
<%
  Else
%>
        <td><img src="<%=showRootDefault%>/img/common/bts_next.gif" alt="다음 페이지가 없습니다."></td>
<%
  End If
%>
       </tr>
       </table>
<%
 End If
%>
      <!-- paging end -->
      </td>
      <td width="10" background="<%=showRootDefault%>/img/common/tbg_paging_r.gif"></td>
     </tr>
    </table>
    <!-- paging end --> 

'asp' 카테고리의 다른 글

Server.CreateObject("Excel.Application") 을 이용하여 엑셀을 출력하는 방법  (10) 2008.12.10
ASP+ORACLE  (0) 2008.12.04
Preventing SQL Injections in ASP  (0) 2008.10.28
asp xmldom 사용법  (0) 2008.09.26
VBSCRIPT ERROR CODE  (0) 2008.09.25

+ Recent posts