ASP中如何表示当前是第几条记录?如每页10条,要显示为第1到10,翻页后照样如此。我的代码如下,怎么修改呢
<%count=10sql="select*from[book]orderbyiddesc"setrs=server.createobject("adodb.record...
<%
count=10
sql="select * from [book] order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=count
rc=rs.recordcount
pgnm=rs.pagecount
if page>pgnm then page=pgnm
if pgnm>1 then rs.absolutepage=page
do while not rs.eof and count>0
count=count-1
%>
<div><ul>
<li>第N条:<a href="#"><%=rs("userhome")%></a></li>
</ul></div>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<table><tr><td>共有<%=rc%>条;第<%=page%>页 共<%=pgnm%>页;
<%if page>1 and pgnm>1 then%>
<a href="?page=1">首页</a> <a href="?page=<%=page-1%>">上一页</a>
<%
end if
if page<pgnm and pgnm>1 then
%>
<a href="?page=<%=page+1%>">下一页</a> <a href="?page=<%=pgnm%>">末页</a>
<%end if%>
</td></tr></table> 展开
count=10
sql="select * from [book] order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=count
rc=rs.recordcount
pgnm=rs.pagecount
if page>pgnm then page=pgnm
if pgnm>1 then rs.absolutepage=page
do while not rs.eof and count>0
count=count-1
%>
<div><ul>
<li>第N条:<a href="#"><%=rs("userhome")%></a></li>
</ul></div>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<table><tr><td>共有<%=rc%>条;第<%=page%>页 共<%=pgnm%>页;
<%if page>1 and pgnm>1 then%>
<a href="?page=1">首页</a> <a href="?page=<%=page-1%>">上一页</a>
<%
end if
if page<pgnm and pgnm>1 then
%>
<a href="?page=<%=page+1%>">下一页</a> <a href="?page=<%=pgnm%>">末页</a>
<%end if%>
</td></tr></table> 展开
3个回答
展开全部
<%
count=10
n=0
sql="select * from [book] order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=count
rc=rs.recordcount
pgnm=rs.pagecount
if page>pgnm then page=pgnm
if pgnm>1 then rs.absolutepage=page
do while not rs.eof and n<count
n=n+1
%>
<div><ul>
<li>第<%=n%>条:<a href="#"><%=rs("userhome")%></a></li>
</ul></div>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<table><tr><td>共有<%=rc%>条;第<%=page%>页 共<%=pgnm%>页;
<%if page>1 and pgnm>1 then%>
<a href="?page=1">首页</a> <a href="?page=<%=page-1%>">上一页</a>
<%
end if
if page<pgnm and pgnm>1 then
%>
<a href="?page=<%=page+1%>">下一页</a> <a href="?page=<%=pgnm%>">末页</a>
<%end if%>
</td></tr></table>
count=10
n=0
sql="select * from [book] order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=count
rc=rs.recordcount
pgnm=rs.pagecount
if page>pgnm then page=pgnm
if pgnm>1 then rs.absolutepage=page
do while not rs.eof and n<count
n=n+1
%>
<div><ul>
<li>第<%=n%>条:<a href="#"><%=rs("userhome")%></a></li>
</ul></div>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<table><tr><td>共有<%=rc%>条;第<%=page%>页 共<%=pgnm%>页;
<%if page>1 and pgnm>1 then%>
<a href="?page=1">首页</a> <a href="?page=<%=page-1%>">上一页</a>
<%
end if
if page<pgnm and pgnm>1 then
%>
<a href="?page=<%=page+1%>">下一页</a> <a href="?page=<%=pgnm%>">末页</a>
<%end if%>
</td></tr></table>
展开全部
<%
for i=1 to count
n=count*(page-1)+i
%>
<li>第<%=n%>条:<a href="#"><%=rs("userhome")%></a></li>
<%
rs.movenext
if rs.eof then eixt for
next
%>
for i=1 to count
n=count*(page-1)+i
%>
<li>第<%=n%>条:<a href="#"><%=rs("userhome")%></a></li>
<%
rs.movenext
if rs.eof then eixt for
next
%>
追问
Microsoft VBScript 编译器错误 错误 '800a03ea'
语法错误
index2.asp,行 152
if rs.eof then eixt for
--------------------^
而且我要的效果是每页都显示为1到10,不是所有的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
再定义个变量i,然后每循环一次加1
追问
请帮我改写一下代码,谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询