主题:  有精通ASP的朋友请帮我解答一下

zhongrq

职务:普通成员
等级:1
金币:0.0
发贴:24
注册:2001/3/29 20:11:22
#12003/2/15 12:51:16
1.我想在asp页面上关联数据库动态显示总页数、当前页数,我用可返回总页数结果为-1,数据库记录数如果不是pagesize的整数倍,返回结果将是小数,不知有什么办法能决解这个问题,要得到当前在第几页该如何做,我用的是Dreamweaver MX.
2.我要在一个页面上显示4个产品图片,通过前一页和后一页超链接翻页,4条记录为一页,4个图片要求用田字形排放,但这样的话就不能用服务器行为的重复区域了,如果一个图片做为一行才可用重复区域行为。
以上两个问题哪位高手能给一个解决方法,急切!



aquadead

职务:普通成员
等级:2
金币:1.0
发贴:589
注册:2002/4/20 18:34:05
#22003/2/15 12:55:42
可以去 www.chinaasp.comwww.chinaaspx.com 问问



zhongrq

职务:普通成员
等级:1
金币:0.0
发贴:24
注册:2001/3/29 20:11:22
#32003/2/15 13:18:06
去http://www.chinaasp.com看哪个地方,论坛吗??



老张

职务:普通成员
等级:5
金币:10.0
发贴:2796
注册:2001/5/11 12:41:55
#42003/2/15 22:52:48
自己改改吧:
1栏分页显示(附显示的形式前页,后页)
2001-11-21 动网先锋

显示的形式
id name
1 juliet
2 cristine
3 boy
4 girl
>>首页 前页 后页 尾页 页数:1/4 4记录/页 总记录数:13条
代码:





<%
dim rs
dim sql
msg_per_page = 4 '定义每页显示记录条数
set rs = server.createobject("adodb.recordset")
sql = "select * from page order by id" '改成你自己的SQL语句
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高

rs.pagesize = msg_per_page '定义分页记录集每页显示记录数
rs.open sql,conn,0,1

if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if not (rs.eof and rs.bof) then '检测记录集是否为空
totalrec = RS.RecordCount 'totalrec:总记录条数
if rs.recordcount mod msg_per_page = 0 then '计算总页数,recordcount:数据的总记录数
n = rs.recordcount\msg_per_page 'n:总页数
else
n = rs.recordcount\msg_per_page+1
end if

currentpage = request("page") 'currentpage:当前页
If currentpage <> "" then
currentpage = cint(currentpage)
if currentpage < 1 then
currentpage = 1
end if
if err.number <> 0 then
err.clear
currentpage = 1
end if
else
currentpage = 1
End if
if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then
currentPage=1
end if
rs.absolutepage = currentpage 'absolutepage:设置指针指向某页开头
rowcount = rs.pagesize 'pagesize:设置每一页的数据记录数

dim i
dim k
%>




<%do while not rs.eof and rowcount > 0%>




<%
rowcount=rowcount-1
rs.MoveNext
loop
end if
end if
rs.close
set rs=nothing
%>

IDname
<%=rs("id")%><%=rs("testname")%>






<%call listPages()%>



<%
sub listPages()
if n <= 1 then exit sub
%>

>>
<%if currentpage = 1 then%>
Top Previous
<%else%>
?page=1">Top
?page=<%=currentpage-1%>">
Previous

<%end if%>
<%if currentpage = n then%>
Next Bottom
<%else%>
?page=<%=currentpage+1%>">Next
?page=<%=n%>">Bottom

<%end if%>

Page:<%=currentpage%>/<%=n%>pages <%=msg_per_page%>notes/page Total:<%=totalrec%>notes


<%end sub%>



zhongrq

职务:普通成员
等级:1
金币:0.0
发贴:24
注册:2001/3/29 20:11:22
#52003/2/16 13:23:41
非常感谢!:)