请ASP高手帮我修改一下这个ASP分页模块

作者&投稿:苍肿 (若有异议请与网页底部的电邮联系)
asp怎么添加分页版块~

找个系统看他的newslist.asp
就可以了。
<%
' ============================================
'////1、2、3、4、5、6、7、8、9 分页代码。
' ============================================
'调用代码:
'-----------------------------------------------------------------------------
'参数说明一下:
'TopicCount 总记录集
'PCount 总页数
'Pama 翻页时本页所带的参数。 如:Pama="&KeyWord=表情&Code=0101&Typeid=12"
'Page 当前页码数

'最后贴出 TurnPage 过程的代码:
'--------------------------------------------------------------------------------
'分页过程
Sub TurnPage(TopicCount,PCount,Pama,PageNo)
Dim TurnInfo,StartPage,EndPage

'进行取分页数,进行循环
if PCount<=9 or PageNo<=5 then
StartPage=1
if PCount>9 then
EndPage=9
else
EndPage=PCount
end if
else
if (PCount-PageNo)>=5 then
StartPage=PageNo-4
EndPage=PageNo+4
else
EndPage=PCount
StartPage=PCount-8
end if
end if

TurnInfo=""&vbcrlf
TurnInfo = TurnInfo&""&vbcrlf

TurnInfo=TurnInfo&" 共"&TopicCount&"条 "&PCount&"页 "&vbcrlf
TurnInfo=TurnInfo&""&vbcrlf

if PageNo<=1 then
TurnInfo=TurnInfo&" 首页 "&vbcrlf
TurnInfo=TurnInfo&" 上页 "&vbcrlf
else
TurnInfo=TurnInfo&" 首页 "&vbcrlf
TurnInfo=TurnInfo&" 上页 "&vbcrlf
end if

for i=StartPage to EndPage step +1
if Clng(PageNo)=Clng(i) then
TurnInfo=TurnInfo&" "&i&" "&vbcrlf
else
TurnInfo=TurnInfo&" "&i&" "&vbcrlf
end if
next

if Clng(PageNo)<Clng(PCount) then
TurnInfo=TurnInfo&" 下页 "&vbcrlf
TurnInfo=TurnInfo&" 末页 "&vbcrlf
else
TurnInfo=TurnInfo&" 下页 "&vbcrlf
TurnInfo=TurnInfo&" 末页 "&vbcrlf
end if

TurnInfo=TurnInfo&" "&vbcrlf
for ii=1 to PCount
TurnInfo=TurnInfo&" <option value=""?Page="&ii&Pama&""""
if Clng(PageNo)=Clng(ii) then TurnInfo=TurnInfo&"selected"
TurnInfo=TurnInfo&"> "&vbcrlf
TurnInfo=TurnInfo&ii&""&vbcrlf
next
TurnInfo=TurnInfo&""&vbcrlf


response.write TurnInfo

End Sub
%>
效果:http://www.nnflower.com/product.asp

<%
sqlstr="select * from [Link] where Link_Show=0 order by Link_CTime desc,Link_Id asc"
rs.open sqlstr,conn,1,3
RS.PageSize=15'设置每页记录数
Dim TotalPages
TotalPage = RS.PageCount
If Request("page") = "" or Request("page") = 0 then
page = 1
Else
page = CINT(Request("page"))
End If
If page>RS.Pagecount Then page=RS.Pagecount
RS.AbsolutePage=page
Dim Totalcount
Totalcount =INT(RS.recordcount)
n=1
while not rs.eof and n
%>
" target="_blank" title="">
<%n=n+1
rs.movenext
wend
%>
<%'这里是分页区,通用
sub spitpage()
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9
If EndPageNum>RS.Pagecount then EndPageNum=RS.Pagecount

response.Write("共有"&totalcount&"个 当前页 "&page&"/"&totalpage&" ")
response.Write(" 首页 ")
if page>1 then
response.Write(" 上一页 ")
end if

For I=StartPageNum to EndPageNum
if Ipage then
response.Write(""&I&" ")
else
response.Write(""&I&" ")
end if
Next

if page<totalpage then
response.Write(" 下一页 ")
end if
response.Write(" 尾页 ")
end sub
call spitpage()%>


from:macho http://www.marcho.cn Q:303302

我给你一个通用的分页代码把
文件名:page.asp
<%
dim pageno '记录第几页

'函数名cut1,参数rs类型为Recordset
'该函数主要将接收一个pageno,并将这个值赋给rs的AbsolutePage
'最终达到指定当前页是第几页
function cut1(rs)
if not rs.eof or not rs.bof then
Dim i
pageno = Request("pageno")
If pageno <= 0 Then
rs.AbsolutePage = 1 '转到第一页
pageno = 1
Else
If CInt(pageno) > CInt(rs.PageCount) Then
pageno = rs.PageCount '转到最后一页
End If
rs.AbsolutePage = pageno
End If
end if
End function

'函数名cut2,参数rs类型为Recordset
'该函数主要将接收一个Request("url")和Request.QueryString,从而取得本页地址栏的内容
'在此基础上,根据当前页数pageno算出各种不同情况下,我们需要的下一页的页数
'最终达到指定下一页地址栏内容
'注:本函数没有对Request.form做处理
function cut2(rs)
Dim urlstring
Dim thisno

urlstring = Request("url") & "?" & Request.QueryString
if Request.QueryString="" then
urlstring = Request("url") & "?" & Request.form
'注:本函数在仅这里对Request.form做处理
end if
If InStr(urlstring, "pageno=") > 0 Then
urlstring = Left(urlstring, InStr(urlstring, "pageno=") - 1)
End If
If ((InStr(urlstring, "&") >= 2) or (InStr(Left(urlstring, Len(urlstring) - 1), "?") >= 2)) Then
urlstring = urlstring & "&"
End If
if InStr(urlstring, "/") >= 2 Then
urlstring1 = split(urlstring, "/")
urlstring = urlstring1(ubound(urlstring1))
end if
if instr(urlstring,"&&") then
urlstring=replace(urlstring,"&&","&")
end if
thisno=pageno 'thisno记录当前页数pageno,以后的pageno将是下一页的页数

Response.Write "<form action='" & Left(urlstring, Len(urlstring) - 1) & "' name=form method=post>"
if not rs.eof or not rs.bof then
Response.Write "<font style={font-size:9pt} color=black>第<font color=red>" & pageno & "</font>页 共<font color=red>" & rs.PageCount & "</font>页<font color=red>" & rs.RecordCount & "</font>条信息 "
else
Response.Write "<font style={font-size:9pt} color=black>第<font color=red>0</font>页 共<font color=red>" & rs.PageCount & "</font>页<font color=red>" & rs.RecordCount & "</font>条信息 "
end if
if not rs.eof or not rs.bof then
if cint(pageno)=rs.pagecount then
response.write "现在是<font color=red>"&(cint(pageno)-1)*rs.pagesize+1&"</font>条---<font color=red>"&(cint(pageno)-1)*rs.pagesize+(rs.recordcount-cint(pageno-1)*rs.pagesize)&"</font>条 "
else
response.write "现在是<font color=red>"&(cint(pageno)-1)*rs.pagesize+1&"</font>条---<font color=red>"&cint(pageno)*rs.pagesize&"</font>条 "
end if
else
response.write "现在是<font color=red>0</font>条---<font color=red>0</font>条"
end if
Response.Write "直接到第"

'文本框用于跟踪当前页数和控制下一页页数(暂停用)
'Response.Write "<input type=text name=pageno size=2 maxlength=2 value=" & pageno & "> 页"

'下拉列表框用于跟踪当前页数和控制下一页页数
Response.Write "<select name=pageno siz1=1 onchange='javascript: form.submit();'>"
for i=0 to rs.PageCount-1
Response.Write "<option value=" & (i+1)
if (i+1)=cint(thisno) then
Response.Write " selected"
end if
Response.Write ">" & (i+1)
next
Response.Write "</select>"
Response.Write "页</font> "
if pageno<=1 then
response.write "<font style={font-size:9pt} color=gray>首页</font> "
response.write "<font style={font-size:9pt} color=gray>上页</font> "
else
Response.Write "<a href='" & urlstring & "pageno=1'><font style={font-size:9pt}>首页</font></a> "
Response.Write "<a href='" & urlstring & "pageno=" & (pageno - 1) & "'><font style={font-size:9pt}>上页</font></a> "
end if
if (cint(pageno)>=cint(rs.pagecount)) then
response.write "<font style={font-size:9pt} color=gray>下页</font> "
response.write "<font style={font-size:9pt} color=gray>末页</font> "
else
Response.Write "<a href='" & urlstring & "pageno=" & (pageno + 1) & "'><font style={font-size:9pt}>下页</font></a> "
Response.Write "<a href='" & urlstring & "pageno=" & rs.PageCount & "'><font style={font-size:9pt}>末页</font></a> "
end if
Response.Write "</form>"
End function

%>
使用的时候用include引用这个页面
并在现实的位置加入
<%= cut1(rs) %>
这样就可以了

这个也是一个分页模块 名字fenye.asp
把数据库的地址直接改一下就能用

<h3>数据集分页实例</h3>
<hr>
<%
dim conn
dim connstr
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql
dim rs
on error resume next
connstr="DBQ="+server.mappath("../northwind.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
set rs=server.createobject("adodb.recordset")
' 打开数据库
const MaxPerPage=10
' 定义每页文章显示数
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
sql="select * from Customers order by CustomerID"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof then 'and rs.bof
response.write "<p align='center'> 噢,还没有文章呢,正在添加中…</p>"
else
totalPut=rs.recordcount
'数据库中文章数totalput
if currentpage<1 then
currentpage=1
end if
'统计总页数currentpage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"fenye.asp"
showContent
showpage totalput,MaxPerPage,"fenye.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"fenye.asp"
showContent
showpage totalput,MaxPerPage,"fenye.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"fenye.asp"
showContent
showpage totalput,MaxPerPage,"fenye.asp"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing

sub showContent
dim i
i=0
do while not rs.eof
%>
<div align=center><a href="openarticle.asp?id=<%=rs("CustomerID")%>"><%=rs("ContactName")%></a>[电话:<%=rs("Phone")%>]</div>
<% ' 选择显示数据库内容
i=i+1
if i>=MaxPerPage then exit do
' 当显示记录大于maxperpage时结束这页
rs.movenext
loop
end sub

function showpage(totalnumber,maxperpage,filename)
' 求出当每页18篇文章时总共的页数
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&">"
response.write "<p align='center'><font color='#000080'>>>分页</font> "
if CurrentPage<2 then
' 显示页数链接的条件
response.write "<font color='#000080'>首页 上一页</font> "
else
response.write "<a href="&filename&"?page=1&>首页</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)
response.write ">下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write "<font color='#000080'>页次;</font><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"页</font>"
response.write "<font color='#000080'>共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font>"
response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength='10' class='smallInput' value='"&Currentpage&"'>"
response.write "<input class=buttonface type='submit' value='转到' name='cndok'></span></p></form>"
end function
%>

这样试试

<%
'+++++++++++++++++++++++++++++++++++++
'◆模块名称: 公共翻页模块
'◆文 件 名: fenye.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")
'如果没有选择第几页,则默认显示第一页;
end if
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 width="258" align=left> 总页数:<font color=#ff3333><%=TotalPage%></font>页
当前第<font color=#ff3333><%=PageNo%></font>页 总共<%=RecordCount%>条 </td>
<td width="308" align="right"> <div align="center">
<%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%>
</div></td>
<td width=189><form name="form1" method="post" action=""> 转到第 <% If TotalPage = 1 Then%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<input type="submit" name="Submit" value="Go" disabled style="background:#d3d3d3">
<%Else%>
<input type=text name=PageNo size=3 >
<input type="submit" name="Submit" value="Go">
<%End If%>
</form>

</td>
</tr>
</table>
<%End Sub%>


asp修改密码方面的,希望得到高手帮助
ID=request.Querystring("id")改成 ID=request("id")试一试,如果还有问题说明 sql="select * from Member where MemberID='"&ID&"'"有问题,说明没有在表中找到符合条件的数据,你看看条件是不是写的不对

有一个ASP上传图片的代码,求高手帮我改下限制它的大小即可,在修改的...
我给你改为限制大小为小于200kb,< Response.Buffer = True Server.ScriptTimeOut=9999999 On Error Resume Next > <!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd"> ...

请问高手们,有没有什么办法可以把这个ASP的这个网页直接进行修改的?
asp.net里有很好的控件,可以直接实现,如果是ASP的话,那就借助css、js了,给每条记录添加一个文本框,用css设为隐藏,当点击员工时,显示,并将原数据显示进来,然后就可修改了,大概的思路就是这样了,应该比较简单,

ASP修改输入框内容使复选框选中,点保存按钮保存数据,请高手帮忙
不好意思,我搞错了,js变量不能传给asp变量的,所以insert语句中的变量获取不到的,但是有另外一种方法:1.保存函数修改为:function saveToDb(){ var strvalue = document.getElementById("pfj").value;parent.location.href = "saveToDb.asp?str="+ strvalue;} saveToDb.asp如下:< str = ...

asp编程问题,在同意页面修改数据的问题,希望高手能帮个忙~
你这个其实刷新本页面就可以了。在iption里面分别给上value值,当点确定之后就会传递一个参数,你在接收页面获取这个参数的值再查询数据库就ok

如何修改ASP后台代码
1。首先你要阅读代码,确定对于admin的判断是以来数据库的,而不是依赖代码的,否则你的修改无效。2。确定你修改的数据库位置是正确的。由于有的ASP程序使用了多重的管理员身份认证,管理员具有多个层次的用户名和密码,因此直接找数据库比较费力。3。数据库里存储的一般是加密后的密码,如果你把加密前...

请问这段asp代码如何修改才可以运行?
程序优化一下:< dim rs,sql Set Rs = Server.CreateObject("ADODB.Recordset")sql="select news_content from news order by id"rs.open conn,sql,1,3 while not rs.eof rs("news_content")=ubb2html(server.htmlencode(rs("news_content")))rs.update rs.movenext wend rs.close set rs...

求救!!asp高手进!!
Private Const adOpenStatic = 3 '\/\/ LockTypeEnum Private Const adLockReadOnly = 1 Private Const adLockPessimistic = 2 Private Const adLockOptimistic = 3 Private Const adLockBatchOptimistic = 4 它默认不加参数时为只读,可写有很多种组合,1,3 为最常用的只读组合,修改一般采用 4,3或3,3。

asp 批量添加,修改、保存,谁帮我解决了这个问题我给他2000财富值!_百 ...
没空改。sql代码中有个in,虽然用此可能会导致数据库执行慢,但数据如果不大于10万条的话,一般是看不出慢来的。比如update 表 set name="214" where id in (1,3,5,8)这样,就会更新id为1,3,5,8的记录。所以,你可用勾选的方法,直接提交。在提交时,form中会将相同name的值做为数组提交...

在ASP中为什么我的用户名密码修改不了,请高手帮我看看
If not rs.eof Then up="update teb_manager set Mname='"&txt_name&"',Mpasswd='" & txt_passwd&"' where Mpasswd='"&passwd&"'"conn.execute(up)alertBack "请牢记新的用户名密码!"end if rs.close conn.close set conn=nothing Else alertBack "原密码不正确,请确认后重新输入!"en...

蒙城县13918428759: 谁帮我修改一下这个ASP代码?
勾关小儿: <%username=request.form("username")if username<>"" then fromwhere =request.form("fromwhere") homepage =request.form("homepage") email =request.form("email") Posttime =now()Dim objXMLDOM, objRootNode, objNode...

蒙城县13918428759: 请高手帮我再修改一下这段ASP代码 -
勾关小儿: <% '连接数据库略 set rs = conn.execute("select FLD_NAME,FLD_ITEM from TBL_Char where FLD_ITEM='"&Request("str输入的文字Name")&"'") do while not rs.eof strname = rs("FLD_NAME") stritem = rs("FLD_ITEM") strsql = "...

蒙城县13918428759: 帮忙修改一段ASP代码!刷新页面换图片的! -
勾关小儿: 我可以.但是需要加一个参数来传递. <% a = Request("a") if a = "" then a = 1 else a = a+1 end if %> 然后你的代码还需要做一下修改 不会追问

蒙城县13918428759: 帮我改一下这个ASP子查询表达式 -
勾关小儿: select * from top_inf where pc_list in (select pc_id from pc_inf where remarks like '%1%')

蒙城县13918428759: 急求高手帮忙修改ASP网站源码
勾关小儿: 增加一个字段,在前台显示信息时,如果这个值为0表示要审核,如为1就显示. 因此在发布时,首先检查下,如果已经登录,那么写入信息时就为1,如果是游客那入写入为0

蒙城县13918428759: ASP朋友帮我改下,在线等... -
勾关小儿: 把tr的循环改为td的循环即可,如下:<TA...

蒙城县13918428759: 急~~~急~~急~~ asp模板 修改 -
勾关小儿: 能用,把后缀改了就可以打开 但是你要测试或者上传的时候把后缀再改回来 或者把后缀改成MDB的 再把连库文件改一下就OK了

蒙城县13918428759: 谁帮我改一段asp代码?
勾关小儿: <!--#include file="inc/conn.asp" --> <% xuehao=request.form("xuehao") str="select * from student where xuehao='"&xuehao&"'" set rs=server.createobject("adodb.recordset") rs.open str,conn,1,3 if not rs.eof then response.write "<...

蒙城县13918428759: 请问高手们,有没有什么办法可以把这个ASP的这个网页直接进行修改的?
勾关小儿: asp.net里有很好的控件,可以直接实现,如果是ASP的话,那就借助css、js了,给每条记录添加一个文本框,用css设为隐藏,当点击员工时,显示,并将原数据显示进来,然后就可修改了,大概的思路就是这样了,应该比较简单,

蒙城县13918428759: 如何在ASP页面上改动 -
勾关小儿: 你打开个ASP文件就知道了哦.看看其中的代码,在<% %>之间的是ASP代码.基本上不要动.然后呢,里面会有一些个HTML语句.因为你只是想美化下.我的建议就是用内嵌的方法来更改.安全的很.在想修改的标签上加 style=""里面写想加的修饰.不明白的Q我 671826

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网