分页程序显示效果如图
首页 上一页 1 2 3 4 5 下一页 转到: 页
点"首页 "没有问题,因为直接指向Index.asp
但是后面的页面都指向最后一页.
代码如下:
<%
sql="select * from ly order by time desc"
set rs= Server.CreateObject("ADODB.RecordSet")
rs.Open sql, Conn, 1, 2
page=Request("page")
if page=0 then
page=1
end if
RecordCount = 0
do while not rs.Eof
RecordCount = RecordCount +1
rs.MoveNext
loop
if not RecordCount=0 then
rs.MoveFirst
end if
pageCount=RecordCount/10
pageCount=int(pageCount)
if (RecordCount mod 10)>0 then
PageCount=PageCount +1
end if
if pagecount=0 then pagecount=1
if page>pagecount then page=pagecount
do while pos<(page-1)*10
pos=pos+1
rs.moveNext
loop
x=0
do while x<10 and not rs.eof%>
//显示内容
<%x=x+1
rs.movenext
loop
rs.close
set rs=nothing
%>
页次:
<%if page="" then
response.write"1"
else
response.write page
end if%>
/ <%=pageCount%> 页 主题数: <%=RecordCount%></td>
<td width="48%" align="right">
<%if page=1 then
response.write"首页"
else
response.write"<a href=index.asp class=a1>首页</a> "
end if%>
<%if page=1 then %>
上一页
<%else%>
<a href="index.asp?page=<%=page-1%>" class="a1">上一页</a>
<%end if%>
<% y=1%>
<%do while y<pagecount+1%>
<a href="index.asp?page=<%=y%>" class=a1><%=y%></a>
<%
y=y+1
loop%>
<%if cint(page)=pagecount then %>
下一页
<%else%>
<a href="index.asp?page=<%=page+1%>" class="a1">下一页</a>
<%end if%>
转到:
<input onMouseOver="this.style.backgroundColor = '#E5F0FF'" style="BORDER-RIGHT: #b4b4b4 1px double; BORDER-TOP:
#b4b4b4 1px double; BORDER-LEFT: #b4b4b4 1px double; COLOR: #8888aa; BORDER-BOTTOM: #b4b4b4 1px double; BACKGROUND-COLOR:
#ffffff" onMouseOut="this.style.backgroundColor = ''" maxlength=3 size=3 name=page value="<%=page%>">
页
<input onMouseOver="this.style.backgroundColor='#FFC864'" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid;
BORDER-LEFT: 1px solid; COLOR: #000000; BORDER-BOTTOM: 1px solid; HEIGHT: 18px; BACKGROU