求FOR分页!急!!

lbui2002 2004-11-22 10:19:55
急求FOR分页,我试了很多,但都以失败告终,请各位大虾帮帮忙啊。
...全文
145 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xyp730000 2004-11-22
  • 打赏
  • 举报
回复
<%
'分页函数
Function New_URL(page,pages) '函数需要的参数有:page(当前页);pages(总页数)
Now_URL="分页函数(3).asp" '本文件的文件名(需要修改)
URL_canshu="id=" &id& "&aaa=" &aaa '需要传递的参数(需要修改)

if URL_canshu <>"" then URL_canshu=URL_canshu &"&"
New_URL_left="<a href='"&Now_URL&"?"&URL_canshu

if page > pages then page = pages
L_L =page-2
if L_L<1 then L_L=1
R_R =L_L + 9
if R_R > pages then
R_R=pages
L_L=R_R-9
if L_L<1 then L_L=1
end if
if page > 1 then New_URL=New_URL_left &"page=1' title='第一页'><font face='Webdings'>9</font></a> " & New_URL_left &"page="&page-1&"' title='上一页'><font face='Webdings'>7</font></a>" '第1页
for i =L_L to R_R
if page=i then
url_url="<font color=red><b>["&i&"]</b></font></a>"
else
url_url="[" &i& "]</a>"
end if
if page > 0 then aaa_aaa=" "
New_URL=New_URL & aaa_aaa & New_URL_left &"page=" &i& "' title='第" &i& "页'>" &url_url
next
if page < pages then New_URL=New_URL &" "& New_URL_left &"page=" &page+1& "' title='下一页'><font face='Webdings'>8</font></a> "& New_URL_left &"page=" &pages& "' title='最后一页'><font face='Webdings'>:</font></a>" '最后一页
End Function

page=cint(request("page"))
if cint(pages)<1 then pages=100
if page<1 then page=10
%>

分页:<%=New_URL(page,pages)%>
cuayi 2004-11-22
  • 打赏
  • 举报
回复
你用时要修改一下,上面是我页面中的分页代码,与你的实际使用不符。
cuayi 2004-11-22
  • 打赏
  • 举报
回复
这个可以不?可以把它编成一个类,以方便下次调用。

<%
dim show_rmb2,show_text,show_rmb
sql = "数据表链接语句"
rs.open sql,conn,1,1
if rs.eof then
else
rs.pagesize = 4
page = cint(Request.QueryString("page"))
if page = "" then page = 1
if page < 1 then page = 1
if page >= rs.pagecount then page = rs.pagecount
rs.absolutepage=page
for i = 1 to rs.pagesize
show_rmb2 = rs("rmb2")
if show_rmb2 = "0" then
show_rmb2 = "没有特价"
end if
if len(rs("text")) > 90 then
show_text = left(rs("text"),90)+"..."
else
show_text = rs("text")
end if
if rs("rmb") = "" then
show_rmb = "没有价格"
else
show_rmb = rs("rmb")
end if
%>

(列表数据)

<%
rs.movenext
if rs.eof then exit for
next
end if
%>

<% if page>1 then %>
<a href="<%= request.servervariables("document_name") %>?page=1">[首页] </a><a href="<%= request.servervariables("document_name") %>?page=<%= page-1 %>">[前页]</a>
<% else %>
<font color="#999999">[首页] [前页]</font>
<% end if %>
<% if page <> rs.pagecount then %>
<a href="<%= request.servervariables("document_name") %>?page=<%= page+1 %>">[后页] </a><a href="<%= request.servervariables("document_name") %>?page=<%= rs.pagecount %>">[尾页]</a>
<% else %>
<font color="#999999">[后页] [尾页]</font>
<% end if %>
<%
rs.close
set rs = nothing
%>
gu1dai 2004-11-22
  • 打赏
  • 举报
回复
纯粹帮你顶。
echina 2004-11-22
  • 打赏
  • 举报
回复
im page,totalpage,i,onlinecount
totalpage=1
onlinecount=0
page=trim(Request.QueryString("page"))
if page<>"" and isnumeric(page) then
page=fix(page)
if page<1 then
page=1
end if
else
page=1
end if
call opendb()
call usertrack(0,"<a href='onlineUsers.asp'>在线用户列表</a>")
sql="select username,isadmin,userip,useragent,lastsubject,activetime from onlineuser where activetime>dateadd('n',(0-" & sessionOut & "),DateAdd('n'," & serverTimeAdd & ",now())) order by username"
rs.open sql,conn,1,1
if not (rs.bof and rs.eof) then
onlinecount=rs.recordcount
rs.pagesize=20
totalpage=rs.pagecount
if page>totalpage then
page=totalpage
end if
rs.absolutepage=page
for i=1 to 20
if i mod 2=0 then
Response.Write " <tr class='rowbg2'>"
else
Response.Write " <tr class='rowbg1'>"
end if
%>
<td width="15%"><%if rs(0)<>"" then%><a href="forumUserInfo.asp?id=<%=Server.UrlEncode(rs(0))%>"><%=rs(0)%></a><%else%>游客<%end if%></td>
<td width="15%"><%if u_admin<>"" then Response.Write rs(2) else Response.Write hideip(rs(2))%></td>
<td width="20%"><%=explorerinfo(rs(3))%></td>
<td width="30%">
<%=rs(4)

%></td>
<td width="20%"> <%=rs(5)%></td>
</tr>
<%
rs.movenext
if rs.eof then
exit for
end if
next
end if
rs.close
set rs=nothing
call closedb()
%></table>
<table cellspacing=0 cellpadding=0 align="center" class="showpage" style="margin-top:-1px">
<tr>
<td width="60%" style="padding-left:12px;"><%
Response.Write "当前在线 <font color='"&colors(12)&"'>"&onlinecount&"</font> 人 "
if page>1 then
Response.Write "<a href="&chr(34)&selfname&"?page=1&ntime="&ntime&chr(34)&">首页</a> "
'else
'Response.Write "第一页 "
end if
'Response.Write "当前第 <select onchange="&chr(34)&"window.location.href='"&selfname&"?page='+this.options[this.options.selectedIndex].text"&chr(34)&">"&vbcrlf
for i=1 to totalpage
Response.Write "<a href="&chr(34)&selfname&"?page="&i&"&ntime="&ntime&chr(34)&">第"&i&"页</a> "
'Response.Write &i&vbcrlf

next
'Response.Write " "&vbcrlf
if totalpage<>page then
Response.Write "<a href="&chr(34)&selfname&"?page="&totalpage&"&ntime="&ntime&chr(34)&">尾页</a>"
'else
'Response.Write "最后一页"
end if
%>
lbui2002 2004-11-22
  • 打赏
  • 举报
回复
晕啊。不懂啊。大家帮帮忙啊。。5~
tatty_bad 2004-11-22
  • 打赏
  • 举报
回复
按我的办法来吧,可以的。。。
lbui2002 2004-11-22
  • 打赏
  • 举报
回复
我晕,我是说FOR分页,while的我有,我总觉得差别很大,总是在这个迷团里走不出来。真是郁闷啊。请各位帮帮忙啊。而且我面临的是没有数据库的,之间用"|"割开的。

如下 :

s1=split(s1,"|")
totalNum=ubound(s1)

for i=1 to totalnum

.....

next



顶上去。
zhangxmyf 2004-11-22
  • 打赏
  • 举报
回复
给你一个最简单的自己研究吧!
<!--#include file="admin.asp"-->
<!--#include file="conn.asp"-->
<%function GetType(typeid)
if typeid=1 then
GetType="家电形象柜"
end if
if typeid=2 then
GetType="音响形象柜"
end if
if typeid=3 then
GetType="数码形象柜"
end if
if typeid=4 then
GetType="展会形象柜"
end if
if typeid=5 then
GetType="其他形象柜"
end if
end function%>
<%if request("action")="del" then
id=request("id")
strSql="delete from tbProduct where id="&id
conn.Execute strSql
end if%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<link href="image.files/style.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="2">
<p> </p>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
<tr class="showbg">
<td height="25" colspan="3" bgcolor="#FFFFFF"><div align="right"><a href="productadd.asp">增加</a>    </div></td>
</tr>
<tr class="showbg">
<td width="51%" height="25" bgcolor="#FFFFFF"> 产品名称</td>
<td width="34%" bgcolor="#FFFFFF">  产品类别</td>
<td width="15%" align="right" bgcolor="#FFFFFF">操作    </td>
</tr>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from tbProduct order by id desc",conn,1,1
if rs.eof then
response.write("<tr><td colspan=3 class=tdd height=24> 没有内容!</td></tr>")
else
IF not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Then
page=1
Else
Page=Int(Abs(Request("page")))
End if
rs.pagesize = 20
total = rs.RecordCount
mypagesize = rs.pagesize
rs.absolutepage = page
do while not rs.eof and mypagesize>0
%>
<tr class="css">
<td height="24" bgcolor="#FFFFFF" class="tdd">  <%=rs("name")%></td>
<td bgcolor="#FFFFFF" class="tdd">  <%=GetType(rs("type"))%></td>
<td align="right" bgcolor="#FFFFFF" class="tdd"><a href="productedit.asp?id=<%=rs("id")%>">修改</a>/<a href="productlist.asp?action=del&id=<%=rs("id")%>" onClick="return confirm('确定删除?');">删除</a>  </td>
</tr>
<%
mypagesize=mypagesize-1
rs.movenext
loop
%>
<tr class="css">
<td height="24" colspan="3" bgcolor="#FFFFFF" class="tdd">
<%response.Write(" 共有<font color=ff6600>"&rs.recordcount&"</font>信息,当前第<font color=ff6600>"&page&"</font>/<font color=ff6600>"&rs.pagecount&"</font>页")
response.Write("                     【<a href=productlist.asp?page=1>最前页</a>】  ")
if page>1 then
response.Write("【<a href=productlist.asp?page="&page-1&">上一页</a>】")
else
response.Write("【<font color='#666666'>上一页</font>】")
end if
response.Write("  ")
if int(page)<>int(rs.pagecount) then
response.Write("【<a href=productlist.asp?page="&page+1&">下一页</a>】")
else
response.Write("【<font color='#666666'>下一页</font>】")
end if
response.Write("  ")
if int(rs.pagecount)>1 then
response.Write("【<a href=productlist.asp?page="&rs.pagecount&">最尾页</a>】  ")
else
response.Write("【<font color='#666666'>最尾页</font>】  ")
end if
%>
</td>
</tr>
<%end if%>
</table>
</body>
</html>
<%
rs.close
set rs=nothing
set conn=nothing
%>
tatty_bad 2004-11-22
  • 打赏
  • 举报
回复
建议将所有数据缓存,然后在关闭的时候再释放
tatty_bad 2004-11-22
  • 打赏
  • 举报
回复
dim m,n,i
m=trim(request("page"))
n=m+10
for i = m to n
response.write "1"
next
lbui2002 2004-11-22
  • 打赏
  • 举报
回复
加分!再加80!明白怎么回事儿了。各位多帮忙啊!
lbui2002 2004-11-22
  • 打赏
  • 举报
回复
呵呵。本人第一次提问啊。各位多帮帮忙啦。
tatty_bad 2004-11-22
  • 打赏
  • 举报
回复
小气鬼,才给20分 :)
gu1dai 2004-11-22
  • 打赏
  • 举报
回复
帮你顶一把

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧