当前位置:编程学习 > asp >>

ASP的N行N列分页代码

答案:显示形式:
ID1 NAME | ID2 NAME
1 JULIET | 2 PALYBOY | 3 PALYBOY
4 BABY | 5 TOM | 6 PALYBOY
7 LENA | 8 JERY | 9 PALYBOY

>>首页 前页 后页 尾页 页数:1/4 6条/页 总记录数:25条


或者:

显示形式:
ID1 NAME | ID2 NAME
1 JULIET | 2 PALYBOY | 3 PALYBOY | 4 PALYBOY
5 BABY | 6 TOM | 7 PALYBOY | 8 PALYBOY
9 LENA | 10 JERY | 11 PALYBOY | 12 PALYBOY

>>首页 前页 后页 尾页 页数:1/4 6条/页 总记录数:25条


设置N行N列都没问题!!!


N行N列分页代码

今天写一段程序涉及到了分行分页代码问了很多地方都得不到答案 无奈之下只能自己来研究了

分行其实不外乎<br>或者<tr><td>的涉及

采用N行1列的分页我想也不需要再罗索什么了 直接切入正题吧 

采用N行M列的分页代码如下 付上详细介绍 相信大家会很容易看懂的

程序代码
'-----member.asp-----

<!--#include file="conn.asp"-->

<%
Set rs=Server.CreateObject("ADODB.Recordset")
Sql="Select * from 表名 order by ID desc"
rs.Open Sql,Connweb,1,1

if request("page")="" then
page=1 
elseif request("page")<1 then
page=1 
else 
page=request("page")
end if

rs.PageSize=12 '每页显示几个记录
rs.AbsolutePage=page
if rs.RecordCount=0 then
Response.Write "没有记录"
else
%>


<%
if rs.eof then 
Response.Write "没有相关记录"
else
response.write ("<table width=500 border=0 cellspacing=0 cellpadding=1><tr>")


for ipage=1 to rs.pagesize
response.write ("<td>")
response.write rs("p_info_name") '您需要显示的字段
response.write ("</td>")
j=j+1

m=4 '假如您是一行4条记录。修改成需要的一行几条

If j>m-1 Then 

Response.Write "</tr><tr>"
j=0
End If


rs.movenext

if rs.eof then exit for
next
Response.Write "</tr></table>"
%> 

<%
end if
end if

'下面的member.asp换成是和本文件一样的文件名
%>
<div align="center"> <%=rs.recordcount%>条记录
当前第<%=page%>页/共有<%=rs.pagecount%>页<a href=><% if page<>1 then %>
<a href=><%else%>
上间
<% end if %>
<% if page<>rs.pagecount then
if page+1>rs.pagecount then
page=rs.pagecount-1
end if

'上面的修正了如果下页没有数据依然可以点击下去的错误
%>
<a href=><%else%>
下间
<% end if %>
<a href=><%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

上一个:PHP完全手册
下一个:ACCESS不要认为改mdb为ASP就能防下载

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,