回 帖 发 新 帖 刷新版面

主题:求高手们赏赐一个简单的分页!

求高手们赏赐一个查询不会丢失变量的分页!感谢非常!狂加分!

回复列表 (共3个回复)

沙发


我也不晓的!


http://www.mzit.com ;IT学习资料网!  请大家多提意见
 如果还不知道可以找我
   www.mzit.com
   www.yidu35.com
   www.yidu35.cn
   www.yidu35.com.cn
   www.yidu35.net
   www.yahucn.com   
   QQ:672700119
   email:studentnet@163.com

板凳

<%
on error resume next
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from exper_shenqing order by id desc"
rs.open sql,conn,3,1
if rs.eof then 
response.Write  "当前数据库中无记录!"
response.end
else
const maxperpage=20 '定义每一页显示的数据记录的常量
dim currentpage '定义当前页的变量
rs.pagesize=maxperpage
currentpage=request.querystring("pageid")
   if currentpage="" or currentpage<1 then
      currentpage=1
      
    else
       currentpage=clng(currentpage)
end if
    if currentpage > rs.pagecount then
      currentpage=rs.pagecount
    end if
'如果变量currentpage的数据类型不是数值型
'将1赋给变量currentpage
if not isnumeric(currentpage) then
currentpage=1
end if

dim totalput,n '定义变量
totalput=rs.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
rs.move(currentpage-1)*maxperpage
i=0
do while i< maxperpage and not rs.eof
%>

'中间是要显示的内容


<%
      i=i+1
    rs.movenext
    loop
    end if
%>



'简单的分页代码(只需要更改一下超链地址)
<td colspan="10" class="tdbg2">页数:<%=currentpage%>/
              <% =n%>
                  <%k=currentpage                    
       if k<>1 then%>
              [<a href="exper.asp?pageid=1">首页</a>] [<a href="exper.asp?pageid=<%=k-1%>">上一页</a>]
              <%else%>
              [首页]&nbsp;[上一页]
              <%end if%>
              <%if k<>n then%>
              [<a href="exper.asp?pageid=<%=k+1%>">下一页</a>] [<a href="exper.asp?pageid=<%=n%>">尾页</a>]
              <%else%>
              [下一页]&nbsp;[尾页]
              <%end if%>
              共有<font color="red"><%=totalput%></font>条记录 
</td>



这两段代码要连起来用,上面的代码可以控制显示的条数,下面的是分页.

3 楼

感谢非常!

我来回复

您尚未登录,请登录后再回复。点此登录或注册