ASP 搜索后,分页不正常
答案:2 悬赏:20
解决时间 2021-02-16 02:15
- 提问者网友:余味
- 2021-02-15 01:40
ASP 搜索后,分页不正常
最佳答案
- 二级知识专家网友:何必打扰
- 2021-02-15 01:51
fox=trim(request("fox"))
keyword=trim(request("keyword"))
session("foxx")=trim(request("keyword"))
bd=session("foxx")
这里好像没意思直接
fox=trim(request("fox"))
keyword=trim(request("keyword"))
bd=keyword
在传到下一页时
"上一页"
"下一页"
使用这种分页代码好用一点
<%sub listpages(mycondition)
if pages<1 then
exit sub
end if
response.write " 页码:"
if p>0 then
response.write "[上十页] "
end if
'-------------------下面写出当前十个页码
for i=1 to 10
if (p*10+i)>pages then exit for
if currentpage=i then
response.write "[ else
response.write "[ end if
response.write "href="&request.ServerVariables("script_name")&"?currentpage="&i&"&p="&p&mycondition&">"&(p*10+i)&"] "
next
'--------------------察看下十页的连接
if (p*10+10) response.write "[下十页]"
end if
'-----------------------------------------------上下页导航
response.write " "
if p>0 and currentpage=1 then
response.write "[上页] "
elseif currentpage>1 then
response.write "[上页] "
end if
' '===上页
if (p*10+currentpage) response.write "[下页] "
elseif (p*10+currentpage) response.write "[下页] "
end if
' '===下页
if (p*10+currentpage)>1 then
response.write "[首页] "
end if
' '===首页
if (p*10+currentpage) response.write "[尾页] "
end if
'===尾页
response.write "第"&(p*10+currentpage)&"/"&Pages&"页 共"&Records&"条记录"
end sub
sub myPages(myRS,mysize) '------mysize为内部变量(主页面没有定义),myRS为主页面传递过来的RS对象(地址传递)
if myRS.eof and myRS.bof then str="没有纪录"
if str="" then
if mysize="" or NOT IsNumeric(mysize) then
mysize=15
end if
myRS.PageSize=mysize
pages=myRS.pagecount
records=myRS.recordcount
On Error Resume Next '取得数字
currentPage=request("currentPage")
if currentPage="" then
currentPage=1
end if
currentPage=CInt(currentPage)
if Err.Number <> 0 Then
currentPage=1
Err.Clear
end if
if currentPage<1 then
currentPage=1
elseIf currentPage>10 then
currentPage=10
end if
'----------------处理p
p=request("p")
if p="" then
p=0
end if
p=CLng(p)
if Err.Number <> 0 Then
p=0
Err.Clear
end if
if p<0 then
p=0
end if
'--判断是否出了页数范围
nowPage=p*10+currentPage
if nowPage>pages then
p=(pages-1)\10
currentPage=((pages-1) mod 10)+1
end if
myRS.absolutepage=p*10+currentPage
else
currentPage=1
records=0
pages=1
end if
end sub
dim pages,records,currentPage,p '--------定义变量,这些变量在主页面中,进行地址传递%>
调用时
myPagesize=10
set rs=server.CreateObject("adodb.recordset")
sql="select * from tsjy "
rs.open sql,conn,1,1
myPages rs,myPagesize
'mycondition="&keyword="&keyword '-----如还有关键字这个附加条件,注意开始有个&。
if not rs.eof then
line=myPagesize
do while not rs.eof and line>0
line=line-1
.....
rs.movenext
loop
end if
<%call listpages(mycondition)%>
求采纳为满意回答。
keyword=trim(request("keyword"))
session("foxx")=trim(request("keyword"))
bd=session("foxx")
这里好像没意思直接
fox=trim(request("fox"))
keyword=trim(request("keyword"))
bd=keyword
在传到下一页时
"上一页"
"下一页"
使用这种分页代码好用一点
<%sub listpages(mycondition)
if pages<1 then
exit sub
end if
response.write " 页码:"
if p>0 then
response.write "[上十页] "
end if
'-------------------下面写出当前十个页码
for i=1 to 10
if (p*10+i)>pages then exit for
if currentpage=i then
response.write "[ else
response.write "[ end if
response.write "href="&request.ServerVariables("script_name")&"?currentpage="&i&"&p="&p&mycondition&">"&(p*10+i)&"] "
next
'--------------------察看下十页的连接
if (p*10+10) response.write "[下十页]"
end if
'-----------------------------------------------上下页导航
response.write " "
if p>0 and currentpage=1 then
response.write "[上页] "
elseif currentpage>1 then
response.write "[上页] "
end if
' '===上页
if (p*10+currentpage) response.write "[下页] "
elseif (p*10+currentpage) response.write "[下页] "
end if
' '===下页
if (p*10+currentpage)>1 then
response.write "[首页] "
end if
' '===首页
if (p*10+currentpage) response.write "[尾页] "
end if
'===尾页
response.write "第"&(p*10+currentpage)&"/"&Pages&"页 共"&Records&"条记录"
end sub
sub myPages(myRS,mysize) '------mysize为内部变量(主页面没有定义),myRS为主页面传递过来的RS对象(地址传递)
if myRS.eof and myRS.bof then str="没有纪录"
if str="" then
if mysize="" or NOT IsNumeric(mysize) then
mysize=15
end if
myRS.PageSize=mysize
pages=myRS.pagecount
records=myRS.recordcount
On Error Resume Next '取得数字
currentPage=request("currentPage")
if currentPage="" then
currentPage=1
end if
currentPage=CInt(currentPage)
if Err.Number <> 0 Then
currentPage=1
Err.Clear
end if
if currentPage<1 then
currentPage=1
elseIf currentPage>10 then
currentPage=10
end if
'----------------处理p
p=request("p")
if p="" then
p=0
end if
p=CLng(p)
if Err.Number <> 0 Then
p=0
Err.Clear
end if
if p<0 then
p=0
end if
'--判断是否出了页数范围
nowPage=p*10+currentPage
if nowPage>pages then
p=(pages-1)\10
currentPage=((pages-1) mod 10)+1
end if
myRS.absolutepage=p*10+currentPage
else
currentPage=1
records=0
pages=1
end if
end sub
dim pages,records,currentPage,p '--------定义变量,这些变量在主页面中,进行地址传递%>
调用时
myPagesize=10
set rs=server.CreateObject("adodb.recordset")
sql="select * from tsjy "
rs.open sql,conn,1,1
myPages rs,myPagesize
'mycondition="&keyword="&keyword '-----如还有关键字这个附加条件,注意开始有个&。
if not rs.eof then
line=myPagesize
do while not rs.eof and line>0
line=line-1
.....
rs.movenext
loop
end if
<%call listpages(mycondition)%>
求采纳为满意回答。
全部回答
- 1楼网友:绝望伪装
- 2021-02-15 02:09
代码太乱了,先说说你可以分为两步来做
第一步先把影片价格为0的先列出来,比如只显示id,并分页
接着再用新的记录集把影片信息读取出业,
但是读取影片信息所用的变量和对象都不能和其它的冲突
所以,分页跟读取影片信息是没有关联的。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯