asp 如何进行行列显示分页?
比如<%SetRs_news=Server.CreateObject("Adodb.RecordSet")SQL="Select*Fromnews"Rs_news.ope...
比如
<%Set Rs_news=Server.CreateObject("Adodb.RecordSet")
SQL="Select * From news"
Rs_news.open sql,conn,1,1%>
<%=rs_news("bt")%>
<%rs_news.movenext
loop%>
如何进行4行2列的分页显示 展开
<%Set Rs_news=Server.CreateObject("Adodb.RecordSet")
SQL="Select * From news"
Rs_news.open sql,conn,1,1%>
<%=rs_news("bt")%>
<%rs_news.movenext
loop%>
如何进行4行2列的分页显示 展开
1个回答
展开全部
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<%
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
%>
<td height="20" ><span>·</span> <a href="http://www.cyxxg.com" target="_blank">
<%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%>
</a>
<%
if i mod 2 =0 then
%>
</td>
</tr>
<%
end if
%>
<%
i=i+1
Rs_news.movenext
loop
%>
</table>
搞定了..这样就可以以列输出了...
其实很简单用<tr>就行了.
下面是分页的实例,自己动手改一下吧!举一反三
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
<tr>
<td height="2" bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="50%" height="20">
<div align="center">发布新闻标题</div></td>
<td>
<div align="center">发布时间</div></td>
<td><div align="center">修改|删除</div></td>
</tr>
<%
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 "<font color=red>今天没有新留言!</font>"
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 i<PageSize
i = i + 1
j=j+1
%>
<tr bgcolor="#FFFFFF">
<td height="1"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> <%=j%>:<a href="news_file.asp?news_id=<%=usrrs("news_id")%>"><%=usrrs("news_title")%></a> </td>
<td><div align="center"><%=usrrs("news_time")%></div></td>
<td><div align="center"><a href="news_edit.asp?news_id=<%=usrrs("news_id")%>">修改</a>|<a href="news_del.asp?news_id=<%=usrrs("news_id")%>">删除</a></div></td>
</tr>
<% usrrs.MoveNext
loop
end if
%>
<form name="form1" method="post" action="news_admin.asp">
<tr bgcolor="#FFFFFF">
<td colspan="4"> <div align="center">
<%
Response.Write "最新留言数:" &TotalRecords
Response.Write " " & "总页数:" &TotalPages
'显示现在是第几页
Response.Write " " &"现在是第"&Session("Page")&"页"
'显示首页、上页、下页和尾页四个按钮
%>
<input name="PageAction" type="submit" value="首页" class="b1" />
<input name="PageAction" type="submit" value="上页" class="b1" />
<input name="PageAction" type="submit" value="下页" class="b1" />
<input name="PageAction" type="submit" value="尾页" class="b1" />
</div>
<%
usrrs.close
conn.close
Set usrrs=Nothing
set conn=Nothing
%> </td>
</tr>
</form>
</table>
<tr>
<%
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
%>
<td height="20" ><span>·</span> <a href="http://www.cyxxg.com" target="_blank">
<%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%>
</a>
<%
if i mod 2 =0 then
%>
</td>
</tr>
<%
end if
%>
<%
i=i+1
Rs_news.movenext
loop
%>
</table>
搞定了..这样就可以以列输出了...
其实很简单用<tr>就行了.
下面是分页的实例,自己动手改一下吧!举一反三
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
<tr>
<td height="2" bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
<td bgcolor="#999999"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="50%" height="20">
<div align="center">发布新闻标题</div></td>
<td>
<div align="center">发布时间</div></td>
<td><div align="center">修改|删除</div></td>
</tr>
<%
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 "<font color=red>今天没有新留言!</font>"
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 i<PageSize
i = i + 1
j=j+1
%>
<tr bgcolor="#FFFFFF">
<td height="1"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20"> <%=j%>:<a href="news_file.asp?news_id=<%=usrrs("news_id")%>"><%=usrrs("news_title")%></a> </td>
<td><div align="center"><%=usrrs("news_time")%></div></td>
<td><div align="center"><a href="news_edit.asp?news_id=<%=usrrs("news_id")%>">修改</a>|<a href="news_del.asp?news_id=<%=usrrs("news_id")%>">删除</a></div></td>
</tr>
<% usrrs.MoveNext
loop
end if
%>
<form name="form1" method="post" action="news_admin.asp">
<tr bgcolor="#FFFFFF">
<td colspan="4"> <div align="center">
<%
Response.Write "最新留言数:" &TotalRecords
Response.Write " " & "总页数:" &TotalPages
'显示现在是第几页
Response.Write " " &"现在是第"&Session("Page")&"页"
'显示首页、上页、下页和尾页四个按钮
%>
<input name="PageAction" type="submit" value="首页" class="b1" />
<input name="PageAction" type="submit" value="上页" class="b1" />
<input name="PageAction" type="submit" value="下页" class="b1" />
<input name="PageAction" type="submit" value="尾页" class="b1" />
</div>
<%
usrrs.close
conn.close
Set usrrs=Nothing
set conn=Nothing
%> </td>
</tr>
</form>
</table>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询