菜鸟请教下分页的问题(已附上源码),各位高手指教下谢谢!!
自己做的管理系统,做分页的时候点下一页直接跳到最后一页,点第一页和上页,页面跳转数据不会变~~谢谢各位高手指教下~~
<!--#include file="conn.asp"-->
<%
dim worktype,p
worktype=request.QueryString("worktype")
p=request.QueryString("page")
if p="" then
p=1
end if
if worktype="" then
%>
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><b>欢迎使用管理系统</b></td>
</tr>
</table>
<%
elseif worktype="add" then%>
<% elseif worktype="mody" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from aa order by texttime desc"
rs.open sql,conn,1,1
rs.pagesize=2
if p>rs.pagecount then
p=rs.pagecount
end if
if not rs.eof then
rs.absolutepage=int(p)
end if
%>
......中间是表单
<table width="600" align="center" border="0" cellpadding="5" cellspacing="0">
<%for n=1 to rs.pagesize%>
<tr>
<td><%=rs("texttopic")%></td>
<td><a href="update.asp?id=<%=rs("id")%>">编辑</td>
<td><a href="delete.asp?id=<%=rs("id")%>">删除</td>
</tr>
<%
rs.movenext
if rs.eof then
exit for
end if
next
%>
<tr>
<td><%if p>1 then%><a href="mody.asp?worktype=<%=worktype%>&page=1">第一页</a>
<a href="mody.asp?worktype=<%=worktype%>&page=<%=p-1%>">上一页</a>
<%end if%></td>
<td>
<%if p<rs.pagecount then%>
<a href="mody.asp?worktype=<%=worktype%>&page=<%=p+1%>">下一页</a>
<a href="mody.asp?worktype=<%=worktype%>&page=<%=rs.pagecount%>">最后一页</a>
<%end if%>
</td>
</tr>
</table>
<%end if
%>