摄影姿势视频:求这种情况下的ASP分页代码

来源:百度文库 编辑:高考问答 时间:2024/04/29 22:20:40
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
—————————————————
<%
set rs=conn.execute("select top 9 * from news order by id desc")
do while not rs.eof
%>
————————————————————
<a href="viewnews1.asp?id=<%=rs("id")%>"><%=rs("title")%></a>

这种情况下谁能给一个精简的分页代码?
注:因为分页没解决,所以用"select top 9"显示最新的9条,只要能分页,这句可取消

下面是我收集的代码,我觉的你应该能用上。如果还不行的话,QQ联系,我帮你解决。
Function ExportPageInfo(ByRef rs,curpage,i,LinkFile)
Dim retval, j, pageNumber, BasePage

retval = "第" & curpage & "页/总" & rs.pagecount & "页 "
retval = retval & "本页" & i & "条/总" & rs.recordcount & "条 "

If curpage = 1 Then
retval = retval & "首页 前页 "
Else
retval = retval & "<a href=''" & LinkFile & "page=1''>首页</a> <a href=''" & LinkFile & "page=" & cstr(curpage - 1) & "''>前页</a> "
End If
If curpage = rs.pagecount Then
retval = retval & "后页 末页"
Else
retval = retval & "<a href=''" & LinkFile & "page=" & cstr(curpage + 1) & "''>后页</a> <a href=''" & LinkFile & "page=" & cstr(rs.pagecount) & "''>末页</a>"
End if

retval = retval & "<br/>"
BasePage = (curpage \ 10) * 10
If BasePage > 0 Then retval = retval & " <a href=''" & LinkFile & "page=" & (BasePage - 9) & "''><<</a>"
For j = 1 to 10
pageNumber = BasePage + j
If PageNumber > rs.pagecount Then Exit For
If pageNumber = Cint(curpage) Then
retval = retval & " <font color=''#FF0000''>" & pageNumber & "</font>"
Else
retval = retval & " <a href=''" & LinkFile & "page=" & pageNumber & "''>" & pageNumber & "</a>"
End If
Next
If rs.pagecount > BasePage Then retval = retval & " <a href=''" & LinkFile & "page=" & (BasePage + 11) & "''>>></a>"

ExportPageInfo = retval
End Function

--------------------------------------------------------------------------------

应用

<%
adoPageRS.open "SELECT * FROM news ORDER BY addtime DESC", conn, 1, 1
if err.number <> 0 then
response.write "数据库操作失败:"&err.description
else
if adoPageRS.eof and adoPageRS.bof then
response.write "没有记录"
else
%>
<div align="center">
<center>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr class="big">
<td width="60%">新 闻 标 题</td>
<td width="25%" align="center">日期</td>
<td width="15%" align="center">操 作</td>
</tr>
<%
adoPageRS.pagesize = 10
adoPageRS.absolutepage = curpage
for i = 0 to 9
%>
<tr>
<td><%= adoPageRS("title") %></td>
<td align="center">
<% = adoPageRS("addtime") %>
</td>
<td align="center"><a href=''newsman.asp?action=edit&id=<%= adoPageRS("id")%>''>编辑</a>
<a href=''javascript:confirmDel(<%= adoPageRS("id") %>)''>删除</a></td>
</tr>
<%
adoPageRS.movenext
if adoPageRS.eof then
i = i + 1
exit for
End If
next
%>
<tr align="center">
<td colspan="3">
<% = ExportPageInfo(adoPageRS, curpage, i, "Newsman.asp?") %>
</td>
</tr>
</table>
</center>
</div>