asp 如何进行行列显示分页?

2024-12-21 21:13:22
推荐回答(1个)
回答1:



<%
i=1
Set Rs_news=Server.CreateObject("Adodb.RecordSet")
SQL="Select top 8 * From news"
Rs_news.open sql,conn,1,1
do while not Rs_news.eof
%>


<%
end if
%>
<%
i=i+1
Rs_news.movenext
loop
%>
·
<%if len(trim(rs_news("bt")))>15 then
response.write left(rs_news(rs("bt")),12)&".."
else
response.write trim(rs_news("bt"))
end if%>

<%
if i mod 2 =0 then
%>

搞定了..这样就可以以列输出了...
其实很简单用就行了.
下面是分页的实例,自己动手改一下吧!举一反三














<%
usrsql="SELECT * from [news_page] order by news_time desc"
Set usrrs = Server.CreateObject("ADODB.Recordset")
usrrs.OPEN usrsql, Conn,3,1
'设置每页的大小
PageSize =100
usrrs.PageSize = PageSize
' 得到总的页数
TotalPages = usrrs.PageCount
' 得到总记录数
TotalRecords = usrrs.RecordCount
'检查记录集是否为空
If TotalRecords<1 Then
Response.Write "今天没有新留言!"
else
' 得到用户选择的动作
PageAction = Request.Form("PageAction")
' 根据动作重设页码
Select Case PageAction
Case "首页" Session("Page")=1
Case "上页" Session("Page")=Session("Page")-1
Case "下页" Session("Page")=Session("Page")+1
Case "尾页" Session("Page")=TotalPages
Case Else Session("Page")=1
End Select
' 检查页码是否越界:1<= Page <=TotalPages
If CInt(Session("Page"))<1 Then
Session("Page")=1
End If
If CInt(Session("Page"))>TotalPages Then
Session("Page")=TotalPages
End If
' 跳转到指定页
usrrs.AbsolutePage = Session("Page")
%>
<%
i=0
j=0
Do While Not usrrs.Eof And ii = i + 1

j=j+1
%>












<% usrrs.MoveNext
loop
end if
%>






发布新闻标题

发布时间
修改|删除
    <%=j%>:"><%=usrrs("news_title")%>
<%=usrrs("news_time")%>

<%
Response.Write "最新留言数:" &TotalRecords
Response.Write "  " & "总页数:" &TotalPages
'显示现在是第几页
Response.Write "  " &"现在是第"&Session("Page")&"页"
'显示首页、上页、下页和尾页四个按钮
%>

 

 

 


<%
usrrs.close
conn.close
Set usrrs=Nothing
set conn=Nothing
%>