帮我解决下分页的问题,马上给分

ASP_sem 2007-07-16 01:40:28
<TABLE cellPadding=1 align="center" cellSpacing=1 align=center border=1 width="900" height="1" >
<%
response.write"<tr>"
response.write"<td width=100> 需求单位 </td>"
response.write"<td width=100> 需求提出人 </td>"
response.write"<td width=100> 主旨 </td>"
response.write"<td width=100> 资讯主办 </td>"
response.write"<td width=100> 需求提出日期</td>"
response.write"<td width=100> 希望上线日期 </td>"
response.write"<td width=100> 预估完成日期 </td>"
response.write"<td width=100> 状态</td>"
response.write"<td width=100> 说明</td></tr>"

Set Rs = server.CreateObject("Adodb.Recordset")
'sql="select APPLY_DEPARTMENT,APPLIER,MAJOR_IDEA,IT_UNDERTAKER,APPLY_TIME,WISH_FINISH_TIME,TOTESTTIME,REQUIRE_ESTI.PHASE from songzw.REQUIRE_BILL inner join REQUIRE_ESTI on songzw.REQUIRE_BILL.IT_NO=REQUIRE_ESTI.IT_NO "

sql="select APPLY_DEPARTMENT,APPLIER,MAJOR_IDEA,IT_UNDERTAKER,APPLY_TIME,WISH_FINISH_TIME,TOTESTTIME,REQUIRE_ESTI.PHASE from songzw.REQUIRE_BILL inner join REQUIRE_ESTI on songzw.REQUIRE_BILL.IT_NO=REQUIRE_ESTI.IT_NO where 1=1"

if len(MAJOR_IDEA)>0 then
sql=sql &" and MAJOR_IDEA like '%"& MAJOR_IDEA &"%'"
end if

if len(APPLY_TIME_start)>1 then
sql=sql &" and APPLY_TIME >='"& APPLY_TIME_start &"'"
end if

if len(APPLY_TIME_end)>1 then
sql=sql&" and APPLY_TIME <='"& APPLY_TIME_end &"'"
end if


if len( WISH_FINISH_TIME_start)>1 then
sql=sql&" and WISH_FINISH_TIME >='"& WISH_FINISH_TIME_start &"'"
end if

if len(WISH_FINISH_TIME_end)>1 then
sql=sql&" and APPLY_TIME <='"& WISH_FINISH_TIME_end &"'"
end if

if len(IT_UNDERTAKER)>1 then
sql=sql&" and IT_UNDERTAKE = '"& IT_UNDERTAKE &"'"
end if

if len(PHASE)>3 then
sql=sql&" and PHASE='"& PHASE &"'"
end if
Rs.open SQL,CONN,1,1

if Not rs.Eof then Rs.MoveFirst

if sql <> "select APPLY_DEPARTMENT,APPLIER,MAJOR_IDEA,IT_UNDERTAKER,APPLY_TIME,WISH_FINISH_TIME,TOTESTTIME,REQUIRE_ESTI.PHASE from songzw.REQUIRE_BILL inner join REQUIRE_ESTI on songzw.REQUIRE_BILL.IT_NO=REQUIRE_ESTI.IT_NO where 1=1" then

Do while Not rs.Eof
nAPPLY_DEPARTMENT=trim(rs.fields("APPLY_DEPARTMENT"))
nAPPLIER=trim(rs.fields("APPLIER"))
nMAJOR_IDEA=trim(rs.fields("MAJOR_IDEA"))
nIT_UNDERTAKER=trim(rs.fields("IT_UNDERTAKER"))
nAPPLY_TIME=trim(rs.fields("APPLY_TIME"))
nWISH_FINISH_TIME=trim(rs.fields("WISH_FINISH_TIME"))
nTOTESTTIME=trim(rs.fields("TOTESTTIME"))
nPHASE=trim(rs.fields("PHASE"))


response.write"<tr>"
response.write"<td width=100>" & nAPPLY_DEPARTMENT & "</td>"
response.write"<td width=100>" & nAPPLIER & "</td>"
response.write"<td width=100>" & nMAJOR_IDEA & "</td>"
response.write"<td width=100>" & nIT_UNDERTAKER & "</td>"
response.write"<td width=100>" & nAPPLY_TIME & "</td>"
response.write"<td width=100>" & nWISH_FINISH_TIME & "</td>"
response.write"<td width=100>" & nTOTESTTIME & "</td>"
response.write"<td width=100>" & nPHASE & "</td></tr>"
Rs.MoveNext
Loop
end if

%>

</table>

我想将查询的结果分页显示

向调用http://www.web23.cn/article/20074/11/638.html
通用分类代码要怎么改,全部分都给你了~~~~~~~~急的胃痛,麻烦麻烦你们~~~~~~~~~~~~~
...全文
183 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ASP_sem 2007-07-17
  • 打赏
  • 举报
回复
没有人帮忙下吗
ASP_sem 2007-07-17
  • 打赏
  • 举报
回复
不知道该怎么修改程序,才能正确的调用,请求各位大虾能就这个通用分页代码和我的程序修改,调用下,谢谢啦~~~~~~~~~~
ASP_sem 2007-07-17
  • 打赏
  • 举报
回复
在大型的ASP项目中,很多的页面都涉及到翻页功能。如果每个页面都写一个翻页的程序的话,这样的工作即降低了工作效率,也不利于工程的模块化,不能使代码重用。因此,把翻页这样的功能模块化是很有必要的。

  设计方法:

  1、调用该模块时,只需要传递记录集和每页显示的记录的条数;
  2、可以点击链接进行翻页,也可以直接输入页码,回车后翻页;
  3、不要考虑文件名,程序的每次翻页都能在当前页面。
  想清楚了上面3个问题,我们的公共翻页模块就可以动手了。

<%
'+++++++++++++++++++++++++++++++++++++
'◆模块名称: 公共翻页模块
'◆文 件 名: TurnPage.asp
'◆传入参数: Rs_tmp (记录集), PageSize (每页显示的记录条数)
'◆输 出: 记录集翻页显示功能
'+++++++++++++++++++++++++++++++++++++
'
Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If

'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<table border=0 width='100%'>
<tr>
<td align=left> 总页数:<font color=#ff3333><%=TotalPage%></font>页
当前第<font color=#ff3333><%=PageNo%></font>页</td>
<td align="right">
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "首页|前页|后页|末页"
Else%>
<a href="<%=fileName%>?PageNo=1">首页|</a>
<%If PageNo - 1 = 0 Then
Response.Write "前页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前页|</a>
<%End If

If PageNo+1 > TotalPage Then
Response.Write "后页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后页|</a>
<%End If%>

<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末页</a>
<%End If%></td>
<td width=95>转到第
<%If TotalPage = 1 Then%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input type=text name=PageNo size=3 value="" title=请输入页号,然后回车>
<%End If%>页
</td>
</tr>
</table>
<%End Sub%>

  当然,大家可以把翻页的链接做成图片按钮,这样的话也面就更加美观了。
  调用方法:
  1、在程序开始或要使用翻页的地方包含翻页模块文件;
  2、定义变量:RowCount,每页显示的记录条数
  3、调用翻页过程:Call TurnPage(记录集,RowCount)
  4、在Do While 循环输出记录集的条件中加上" RowCount > 0 " 条件
  5、在循环结束 "Loop前" 加上: RowCount = RowCount - 1

'-----------------------------------------------------
调用范例:
文件名:News.asp
<%
Dim Conn,Rs_News
Set Conn = server.CreateObject("ADODB.CONNECTION")
Conn.Open "cpm","cpm","cpm"

Dim Sql
Sql = "Select * from News"
Set Rs_News = Server.CreateObject("ADODB.RECORDSET")
Rs_News.Open Sql,Conn,1,3 '获取的记录集

'公共翻页模块开始%>
<!--#include file=../Public/TurnPage.asp-->
<%
Dim RowCount
RowCount = 10 '每页显示的记录条数
Call TurnPage(Rs_News,RowCount)
'公共翻页模块结束%>

<table width=100%>
<tr>
<td>新闻编号</td>
<td>新闻标题</td>
<td>发布日期</td>
<tr>
<%
If Not Rs_News.eof
Do while Not Rs_News.eof and RowCount>0
%>
<tr>
<td><%=Rs_News("ID")%></td>
<td><%=Rs_News("Name")%></td>
<td><%=Rs_News("Date")%></td>
<tr>
<%
RowCount = RowCount - 1
Rs_News.MoveNext
Loop
End If
%>

这个是我想用的通用分页代码
number123456 2007-07-17
  • 打赏
  • 举报
回复
<%
dim Rrout
Sub PageCut(page)
Urlqueryt = Request.QueryString
If Urlqueryt <> "" then
Rrobt = Instr(Urlqueryt,"page=")
If Rrobt > 0 then
Rroct = Instr(Rrobt,Urlqueryt,"&",vbTextCompare)
If Rroct > Rrobt then
If Rroct > 1 then aa = aa + 1
Rront = mid(Urlqueryt,aa,Rroct-aa)
Rrout = "?"&Replace(Urlqueryt,Rront,"")&"&page="
Else
Rrout = "?"&left(Urlqueryt,Rrobt-1)&"page="
End If
Else
Rrout = "?"&Urlqueryt & "&page="
End If
Else
Rrout = "?page="
End If
%>
<a href="<%=Rrout&page-1%>">上一页</a> 
<%
pagestr = 1
If page > 5 then pagestr = page -5
For pagei = pagestr to page-1
%>
<a href="<%=Rrout&pagei%>">[<%=pagei%>]</a> 
<%
Next
Epage = page + 5
If page + 5 >= paper then Epage = paper
For pageii = page to Epage
If pageii = ccur(page) then
%>
<font color="#FF0000">[<%=pageii%>]</font> 
<%
Else
%>
<a href="<%=Rrout&pageii%>">[<%=pageii%>]</a> 
<%
End If
Next
%>
 <a href="<%=Rrout&page+1%>">下一页</a>
<%
End Sub
%>
调用的时候<%call PageCut(当前页数)%>
显示结果"上一页 1 2 3 4 5 6 下一页"
Dim Rrout '调用url传递的参数,页面地址
ASP_sem 2007-07-17
  • 打赏
  • 举报
回复
我主要是想根据那个通用的分页,学习怎么调用,以后就指导怎么调用了,帮我下,拜托各位~
Joson.e8love 2007-07-17
  • 打赏
  • 举报
回复

'***********************************************
'过程名:doMyData
'作 用:give the data form mydatable
'intPageZize 分页大小 每页显示 intPageZize 条记录
public Tcurrentpage,total,totalpage ,intPageZize,maxpage
'***********************************************

Sub doMyData(rsname,intPageZize)

'dim Tcurrentpage,total,totalpage

maxpage=intPageZize
rsname.pagesize=maxpage

total=rsname.recordcount
totalpage=rsname.pagecount

if maxpage>total then maxpage=total

if Trim(Request.QueryString("page"))="" then

Tcurrentpage=1

Else
if cint(Trim(Request.QueryString("page")))>totalpage then

'If totalpage>rsname.pagecount Then totalpage=rsname.pagecount
Tcurrentpage=totalpage
else
Tcurrentpage=cint(Trim(Request.QueryString("page")))

end if
end if
rsname.absolutepage=Tcurrentpage


'dim i
'do while not rsname.eof or rsname.bof
'i=i+i

End Sub

'***********************************************
'过程名:endMyData
'作 用:read the data and show page

'***********************************************

Sub endMyData(stype,typeid)

'rsname.Movenext
'if i>maxpage then exit do

'loop

Str="<table align='right'><tr><td>"&_
"当前第<font color='#FF0000'>"& Tcurrentpage & "</font>"&_
"页 总共<font color='#FF0000'>"& totalpage &"</font>页 共<font color='#9933FF'>"& total &"</font>条信息"

If Tcurrentpage=1 Then
Str=Str+ "[首页] [上一页]"
Else
Str=Str+"[<a href='?page=1&"&stype&"="&typeid&"'>首页</a>]"
Str=Str+"[<a href='?page="& Tcurrentpage-1 &"&"&stype&"="&typeid&"'>上页</a>]"
End If

If Tcurrentpage=totalpage Then
Str=Str+"[下一页] [尾页]"
Else
Str=Str+"[<a href='?page="& Tcurrentpage+1 &"&"&stype&"="&typeid&"'>下页</a>] [<a href='?page="& totalpage &"&"&stype&"="&typeid&"'>尾页</a>]"
End If

Str=Str+"</td></tr></table>"

Response.write(Str)

End Sub





Sub doMyDataen(intPageZize)


maxpage=intPageZize
rs.pagesize=maxpage

total=rs.recordcount
totalpage=rs.pagecount

if maxpage>total then maxpage=total

if Trim(Request.QueryString("page"))="" then

Tcurrentpage=1

Else
if cint(Trim(Request.QueryString("page")))>totalpage then

'If totalpage>rs.pagecount Then totalpage=rs.pagecount
Tcurrentpage=totalpage
else
Tcurrentpage=cint(Trim(Request.QueryString("page")))

end if
end if
rs.absolutepage=Tcurrentpage


End Sub

自己看下哪个实用 吧 
代码绝对没错 就看你会改不 呵呵
zhangjingcheng 2007-07-16
  • 打赏
  • 举报
回复
先创建一个rscL记录集
'===========================
set rsCL=server.CreateObject("adodb.recordset")
mysql = "select * from tbl_customer order by id desc"
rsCL.open mysql,conn,1,1
'=================================================
利用
while not rscl.eof
response.write rscl.fields("f1")
rscl.movenext
wend
输出所有记录。
利用下面代码替换while not rscl.eof
'===============================================
i = 1
PageNo=replace(request("PageNo"),"'","")
if not Isnumeric(PageNo) then
PageNo=1
end if
rsCL.pagesize=30 '每页多少纪录
TotalPages=rsCL.pagecount
if PageNo="" or PageNo<1 then
PageNo=1
end if
if len(PageNo)>=5 then PageNo=1
if cint(pageNo)>cint(totalpages) then
pageNo=rsCL.pagecount
end if
totalpage=rsCL.pagecount
totalrecord=rsCL.recordcount
rsCL.AbsolutePage = PageNo
RowCount=rsCL.pagesize
while not rsCL.eof and Rowcount>0
一行显示三天记录
'===================================================
for i=1 to rs.pagecount

<tr>if i mod 3=0 then<td>asdasd</td></tr>
else
<td>asdasdasd</td>
end if
rs.movnext
next

利用下面代码替换wend
'===================================================
i = i + 1
rowcount=rowcount-1
rsCL.movenext
wend
'===================================================

下面是现实上一页下一页的代码,一般放在表格下面就行了

<form name="frmPage" action="?id=1" method="post">
<table width="100%" align="center" bgcolor="#FFFFFF" class="no12">
<tr>
<td width="36%" height="23" align="center" class="black">
<%
if pageNo="" then pageno=1
if totalPages="" then TotalPages=1
if PageNo > 1 Then
response.write "<a href=?PageNo=1&id=1>首页</a> | <a href=?PageNo=" & (PageNo-1) & "&id=1>上一页</a> | "
end if
if TotalPages > 1 and cint(PageNo) <> cint(TotalPages) then
response.write "<a href=?PageNo=" & (PageNo+1) & "&id=1>下一页</a> | <a href=?PageNo=" & TotalPages & "&id=1>末页</a> "
end if
%> </td>
<td width="19%" align="left" class="black">总共<%=TotalRecord%>条记录</td>
<td width="14%" align="left"><%Response.Write "Page: 转到第"& PageNo &" / "& TotalPages &""%></td>
<td width="4%" align="left"><input name="pageNo" type="text" id="pageNo" size="4" maxlength="5" /></td>
<td width="27%" align="left"><input name="button2" type="submit" id="button2" value="GoTo" style="border:1 solid #FFFFFF" /></td>
</tr>
</table>
</form>
ASP_sem 2007-07-16
  • 打赏
  • 举报
回复
能帮我看看我应该怎么调用这个通用的分页代码吗,55555555谢谢你们
baijianlong813 2007-07-16
  • 打赏
  • 举报
回复
http://hi.baidu.com/273313672/blog/item/778fed0039795c85e850cd27.html
你看一下
ASP_sem 2007-07-16
  • 打赏
  • 举报
回复
帮忙~~

28,391

社区成员

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

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