⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 分页显示.txt

📁 教学评估网,毕业作品,ASP,如果有用到的可以
💻 TXT
字号:
ASP分页代码 
<!-- #i nclude file="../conn.asp" -->    //(Yoko:路径按自己的设置好)
<%
dim i,intPage,page,pre,last,filepath
  set rs = server.CreateObject("adodb.recordset")
   sql="select * from user order by user_ID desc"
      rs.PageSize = 20         //(Yoko:这里设定每页显示的记录数
      rs.CursorLocation = 3
      rs.Open sql,conn,0,2,1   //(Yoko:'这里执行你查询SQL并获得结果记录集
      pre = true
      last = true
      page = trim(Request.QueryString("page"))
      
      if len(page) = 0 then
                  intpage = 1
                  pre = false
      else
          if cint(page) =< 1 then
               intpage = 1
               pre = false
          else
              if cint(page) >= rs.PageCount then
                  intpage = rs.PageCount
                  last = false
              else
                   intpage = cint(page)
             end if
         end if
      end if
    if not rs.eof then
         rs.AbsolutePage = intpage
    end if
%>
<!--循环开始-->
 <%    
   for i=1 to rs.PageSize
     if rs.EOF or rs.BOF then exit for
  %>
      ..................
     //(Yoko:要循环显示的内容  )..................
      ...................
   <%  
     rs.movenext
    next
   %>
<!--循环体结束
分页部分:-->
 <table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
   <tr>
     <%if rs.pagecount > 0 then%>
     <td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
     <%else%>
    <td width="41%" align="left">当前页0/0</td><%end if%>
    <td width="46%" align="right"> <a href="本页.asp?page=1">首页</a>| 
     <%if pre then%>
     <a href="本页.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
     <%if last then%>
      <a href="本页.asp?page=<%=intpage +1%>">下页</a> |<%end if%>
      <a href="本页.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
      <select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
      <%
       for i = 1 to rs.PageCount
       if i = intpage then%>
       <option value="本页.asp?page=<%=i%>" selected><%=i%></option>
     <%else%>
       <option value="本页.asp?page=<%=i%>"><%=i%></option>
        <%
          end if
        next
        %>
     </select>页</font> 
    </td>
    </tr>
   </table>

 

 

下面是CSDN的:


<%

         dim Conn,RS,sqlStr,PageSize,RowCount,TotalPages,PageNo,Position,PageBegin,PageEnd

         set Conn= Server.CreateObject("ADODB.Connection")

         set RS = Server.CreateObject("ADODB.RecordSet")

         Conn.open "provider=sqloledb;data source=127.0.0.1;user id=sa;password=;initial catalog=zjydata"

         sqlStr="select * from Items order by iID"

         RS.open sqlStr,Conn,1,1

         PageSize=10

         If RS.RecordCount=0 then

         %>

                   <TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=1 style='font-size:9pt'>

                   <TR bgcolor=#003366 height=20px>

                   <TD align=center><font color=#FFFFFF>商品代码</font></TD>

                   <TD align=center><font color=#FFFFFF>商品名称</font></TD>

                   <TD align=center><font color=#FFFFFF>型号规格</font></TD>

                   <TD align=center><font color=#FFFFFF>计量单位</font></TD>

                   <TD align=center><font color=#FFFFFF>参考进价</font></TD>

                   <TD align=center><font color=#FFFFFF>参考售价</font></TD>

                   <TD align=center><font color=#FFFFFF>备注</font>

                   </TR>

                   <TR height=20px>

                   <TD align=center>没有任何商品信息!</TD>

                   <TR>

                   </TABLE>

         <%

         else

                   RS.PageSize = Cint(PageSize)

                   TotalPages=RS.PageCount

                   PageNo=Request.QueryString("PageNo")

                   if PageNo="" or PageNo<1 Then

                            PageNo = 1

                   end if

                   RS.AbsolutePage = PageNo

                  Position=RS.PageSize*PageNo

                   PageBegin=Position-RS.PageSize+1

                   if Position <RS.RecordCount then

                            PageEnd=Position

                   else 

                            PageEnd= RS.RecordCount

                   end if 

                   %>

                   <TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=1 style='font-size:9pt'>

                   <TR>

                   <TD width=20%>

                   <%

                            Response.Write "页:"& PageNo &" / "& TotalPages &" | 记录:"& PageBegin & " - " & PageEnd & " / " &RS.RecordCount 

                   %>

                   </TD>

                   <TD align=right>

                   <%

                            if PageNo > 1 Then 

                                     response.write "<a href=list.asp?PageNo=1>首页</a>&nbsp;<a href=list.asp?PageNo=" & (PageNo-1) & ">上页</a>&nbsp;"

                            end if 

                            if  TotalPages > 1 and  cint(PageNo) <> cint(TotalPages) then 

                                     response.write "<a href=list.asp?PageNo=" & (PageNo+1) & ">下页</a>&nbsp;<a href=list.asp?PageNo=" & TotalPages & ">末页</a>&nbsp;"

                            end if 

                   %>

                   </TD>

                   </TR>

                   <TR bgcolor=#003366 height=20px>

                   <TD align=center width=20%><font color=#FFFFFF>商品代码</font></TD>

                   <TD align=center width=30%><font color=#FFFFFF>商品名称</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>型号规格</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>计量单位</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>参考进价</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>参考售价</font></TD>

                   <TD align=center width=18%><font color=#FFFFFF>备注</font></TR>

                   <%

                   RowCount = RS.PageSize

                   dim color1,color2

                   color1="#dddddd"

                   color2="#eeeeee"

                   Do While Not RS.EOF and RowCount > 0 

                   Response.Write "<TR height=20px bgcolor="

                   %>

                   <%

                            if RowCount mod 2=0 then:response.write color1 else:response.write color2

                   %>

                   <%

                            Response.Write ">"

                   %>

                   <TD><span><a href=manage.asp?id=<%=rs(0)%>><% =RS("vCode")%></a></span></td> 

                   <TD><span><% =RS("vName")%></span></td> 

                   <TD><span><% =RS("vSpec")%></span></TD>

                   <TD><span><% =RS("vUnit")%></span></td>

                   <TD><span><% =RS("fInPrice")%></span></td> 

                   <TD><span><% =RS("fOutPrice")%></span></TD>

                   <TD><span><% =RS("vDescription")%></span></td>

                   </TR>

                   <%

                   RowCount = RowCount - 1

                   RS.MoveNext

                   Loop

                   Conn.Close

                   set RS = nothing

                   set Conn = nothing

                   %>

                   <TR bgcolor=#003366 height=20px>

                   <TD align=center width=20%><font color=#FFFFFF>商品代码</font></TD>

                   <TD align=center width=30%><font color=#FFFFFF>商品名称</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>型号规格</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>计量单位</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>参考进价</font></TD>

                   <TD align=center width=8%><font color=#FFFFFF>参考售价</font></TD>

                   <TD align=center width=18%><font color=#FFFFFF>备注</font>

                   </TR>

                   <TR>

                   <TD>

                   <%

                            For i=1 to TotalPages

                                     if CInt(PageNo) = CInt(i) then

                                               response.write "["&i&"]"

                                     else

                                               response.write "&nbsp<a href=list.asp?PageNo="&i&">"&i&"</a>&nbsp"

                                     end if

                            Next

                   %>

                   </TD>

                   </TR>

                   </TABLE>

                   <% 

         End if

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -