使用简单asp分页代码(项目中)

只要把红色的套到你的网页中就可以

index.asp页面代码:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="page.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link type="text/css" href="main.css" rel="stylesheet" />
</head>

<body>
<!--#include file="toper.asp"-->

<!--博友列表-->
<div id="blog">
 <h3>博友列表</h3>
 <div>
 <%
  for i=1 to rs.pagesize
   if rs.eof then exit for '如果没有数据就退出循环
 %>
  <dl>
   <dt><%=rs("u_username")%></dt>
   <dd><img src="<%=rs("u_face")%>" alt="<%=rs("u_username")%>" /></dd>
   <dd>给他送花 | 写短信</dd>
   <dd>加为好友 | 写留言</dd>
  </dl>
 <%
  rs.movenext '每循环一次,指针直到下一条
  next
 %>
 <!-----------------分页代码开始!--------------------->
 <div id="page">
  共有<font color="#FF0000"><%=rs.recordcount%></font>条数据&nbsp;
  <%if rs.pagecount>0 then%>
   当前<%=intpage%>/<%=rs.pagecount%>页
  <%else%>
   当前页0/0
  <%end if%>
  <!--------------------上面分页代码主要判断多少页现在在第几页!-------------------------->
   <a href="blog.asp?page=1">首页</a>&nbsp;
  <%if pre then%> 
   <a href="blog.asp?page=<%=intpage-1%>">上一页</a>&nbsp;
  <%end if%>
  <%if last then%>
   <a href="blog.asp?page=<%=intpage+1%>">下一页</a>&nbsp;
  <%end if%>
   <a href="blog.asp?page=<%=rs.pagecount%>">尾页</a>&nbsp;
  转到第
   <select name="sel_page" οnchange="javascript:location=this.options[this.selectedIndex].value;" style="border:1px solid #ccc;">
    <%
     for i=1 to rs.pagecount '第1页到最后一页
     if i=intpage then
    %>
     <option value="blog.asp?page=<%=i%>" selected="selected"><%=i%></option>
    <%else%>
     <option value="blog.asp?page=<%=i%>"><%=i%></option>
    <%
    end if
     next                    'for和next是一对,if和enf if是一对
    %>
   </select>
  页
 </div>   
 </div>
</div>

<!--#include file="footer.asp"-->
</body>
</html>


 

page.asp代码:这个页面你只要改数据库名称id像我下面使用的就是u_id

<%
dim i,intPage,page,pre,last,filepath
  set rs = server.CreateObject("adodb.recordset")
   sql="select * from u_user order by u_id desc"
      rs.PageSize = 28         '这里设定每页显示的记录数
      rs.CursorLocation = 3
      rs.Open sql,conn,1,3     '这里执行你查询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
%>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值