下面代码多行多列分页该怎么改??

cnljc 2009-08-14 03:36:42
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<% sql="select * from db_news order by newsid desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
i=0
rs.pagesize=20 '定义一页显示的记录数目
zs=rs.recordcount '获取记录总数目
zy=rs.pagecount '获取分页的数目
nowye=request("ye") '用request获取当前页数
if nowye="" then nowye=1
nowye=cint(nowye)
if nowye > zy then nowye=1
rs.absolutepage=nowye
'n=1
do while not rs.eof and rs.pagesize
%>
<td width="25%">
<div align="center">
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"> <img src='<%=rs("photo")%>' width="180" height="116" border="0" /></a><br />
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"><strong><font color="#996600" style="font-size:14px "><%=rs("title")%></font></strong></a><br><br><br>
</div>

</td>
<% i=i+1
if i mod 4 = 0 then
Response.Write "</td></tr>"
end if

rs.movenext
loop
%>
</tr>
</table>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="right">
第<% =nowye %>页/共<% =zy %>页  
<% If nowye <=1 then %>上一页
<% else %>
<a href="?ye=<%=nowye-1%>">上一页</a>
<% End If %>
<% if nowye >=zy then %>
下一页
<% else %>
<a href="?ye=<%=nowye+1%>">下一页</a>  
<% End If %>
</div>
</td>
</tr>
</table>
...全文
142 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2009-08-14
  • 打赏
  • 举报
回复

<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<%
sql = "select * from db_news order by newsid desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' 设置CursorLocation

rs.open sql,conn,3,1
rs.pagesize=20 '定义一页显示的记录数目
zs=rs.recordcount '获取记录总数目
zy=rs.pagecount '获取分页的数目
nowye=request("ye") '用request获取当前页数
if nowye="" then nowye=1
nowye=cint(nowye)
if nowye > zy then nowye=1
rs.absolutepage=nowye

n = 4
i = 0
do while not rs.eof and i<rs.pagesize
If i Mod n = 0 Then Response.Write "<tr>"
%>
<td width="25%">
<div align="center">
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"> <img src='<%=rs("photo")%>' width="180" height="116" border="0" /></a><br />
<a href="info.asp?newsid=<%=rs("newsid")%>" target="_blank"><strong><font color="#996600" style="font-size:14px "><%=rs("title")%></font></strong></a><br><br><br>
</div>

</td>
<%
If i Mod n = n-1 Then
Response.Write "</tr>"
Else
If i = rs.RecordCount-1 Then
s = ""
For k = 1 To n - (i Mod n) -1
s = s & "<td></td>"
Next
Response.Write s & "</tr>"
End If
End If
rs.movenext
i = i + 1
loop
%>
</table>

mkcat 2009-08-14
  • 打赏
  • 举报
回复
<%
sql="SELECT * FROM message ORDER BY ID DESC"
set rs=Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
if not rs.eof then '如果表中有数据的时候

pagesUrl="?" '分页连接页面变量
pagesSize=2 '每页显示数量
if request("page")="" then '取得当前页码
thisPage=1
else
thisPage=cint(request("page"))
end if

rs.pagesize=pagesSize '设置RS对象中的每页显示数量
rs.absolutepage=thisPage '设置RS对象中的当前页
allPages=rs.pagecount '取得RS对象中所返回的分页总数
allRecords=rs.recordcount '取得RS对象返回的记录总数

do while not rs.eof
i=i+1 '开始统计一次循环显示的记录数量
%>
<%
if i>=pagesSize then exit do '当显示的记录数大于或等于指定的每页显示数量时跳出DO循环
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
<%
if allPages > 0 then '当RS对象的分页总数达到一页的时候才显示下面内空

'**传统分页**
response.write "当前页<font color='red'>"&thisPage&"</font>/<font color='red'>"&allPages&"</font>, 共<font color='#ff0000'>"&allRecords&"</font>条记录, 每页<font color='red'>"&pagesSize&"</font>条"

if thisPage<=1 then '当前页小于或等于第一页的时候
response.write " 首页 上一页 "
else
response.write " <a href="""&pagesUrl&"page=1"">首页</a> <a href="""&pagesUrl&"page="&(thisPage-1)&""">上一页</a> "
end if

if thisPage>=allPages then '当前大于或者等于总页数(即最后一页)的时候
response.write " 下一页 尾页 "
else
response.write " <a href="""&pagesUrl&"page="&(thisPage+1)&""">下一页</a> <a href="""&pagesUrl&"page="&allPages&""">尾页</a> "
end if

'**快速跳转分页**
response.write "<select name='select' onchange=""if(this.options[this.selectedIndex].value!=''){location='"&pagesUrl&"page='+this.options[this.selectedIndex].value;}"">"
for i=1 to allPages
if thisPage=i then
response.write "<option value='"&i&"' selected>第"&i&"页</option>"
else
response.write "<option value='"&i&"'>第"&i&"页</option>"
end if
next
response.write "</select>"

end if
%>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧