| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 614 人关注过本帖
标题:分页就是会错
只看楼主 加入收藏
jsxhyj
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-8-7
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:4 
分页就是会错
每次点下一页的时候就会错,感觉里面太乱,请高手帮我修正一下,我是新手

<%
bigclass=request.QueryString("bigclass")
smallclass=request.QueryString("smallclass")
if smallclass="" then
set rs_small=server.createobject("adodb.recordset")
sqltext4="select * from smallclass_new where bigclassname='"&bigclass&"' order by idpx asc"
rs_small.open sqltext4,conn,1,1   
smallclass=rs_small("smallclassname")
rs_small.close
set rs_small=nothing
end if
%>
<html>
<TITLE><%if smallclass="" then%><%=bigclass%><%else%><%=smallclass%><%end if%> - <%=SiteTitle%></TITLE>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name="description" content="<%=Sitedescription%>">
<meta name="keywords" content="<%=Sitekeywords%>">
<!-- #include file="Head.asp" -->
<table width="992" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td background="images_pic/bg.jpg"><table width="972" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="208" align="left" valign="top"><table width="190" border="0" cellpadding="0" cellspacing="0" class="allp">
          <tr>
            <td height="30" class="left_lm"><%=bigclass%></td>
          </tr>
          <tr>
            <td><%
set rs_news=server.createobject("adodb.recordset")
sqltext4="select * from smallclass_new where bigclassname='"&bigclass&"' order by idpx asc"
rs_news.open sqltext4,conn,1,1   
do while not rs_news.EOF
%><a href="news.asp?bigclass=<%=server.URLEncode(rs_news("bigclassname"))%>&smallclass=<%=server.URLEncode(rs_news("smallclassname"))%>" class="leftnav<%if rs_news("smallclassname")=smallclass then%>_h<%end if%>"><%=rs_news("smallclassname")%></a>
<%
rs_news.MoveNext
loop
rs_news.close
set rs_news=nothing
%>
            </td>
          </tr>
        </table>
<!-- #include file="left.asp" -->
        </td>
        <td width="764" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td bgcolor="#e5e5e5"><span class="wz">您的当前位置:<a href="<%=SiteUrl%>" title="<%=SiteName%>" class="hui">首页</a> &gt; <a href="news.asp?bigclass=<%=server.URLEncode(bigclass)%>" title="<%=bigclass%>" class="hui"><%=bigclass%></a>  &gt; <%=smallclass%></span><span class="fentitle"><%=smallclass%></span></td>
          </tr>
          <tr>
            <td class="content"><table width="744" border="0" cellpadding="0" cellspacing="0">
<%
page=clng(request("page"))         
Set rs=Server.CreateObject("ADODB.RecordSet")
if BigClass<>"" and SmallClass <>"" then
sql="select * from news where BigClassName='"&BigClass&"' and SmallClassName='"&SmallClass&"' order by idpx desc"
rs.Open sql,conn,1,1
elseif BigClass<>"" then
sql="select * from news where BigClassName='"&BigClass&"' order by idpx desc"
rs.Open sql,conn,1,1
end if
if rs.eof and rs.bof then
  response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page  
for j=1 to rs.PageSize
%>
              <tr>
                <td width="23" height="35" align="center" class="downxu" ><span class="downdian"><img src="images_pic/biaod.gif" width="4" height="6" /></span></td>
                <td width="589" class="downxu"><a href="info.asp?id=<%= RS("id") %>" title="<%=rs("title")%>" class="font14px" style="<%if rs("color1")<>"" then%>color:<%=rs("color1")%>;<%end if%><%if rs("ztcu")="1" then%>font-weight: bold;<%end if%>"><%=rs("title")%></a></td>
                <td width="132" align="right" class="downxu"><font class="adddate"><%=FormatDateTime(RS("AddDate"),2)%></font></td>
              </tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
              <tr valign="bottom">
                <td height="50" colspan="3" align="right" ><form method="post" action="news.asp?BigClass=<%=BigClass%>&SmallClass=<%=SmallClass%>">
                    <%if Page<2 then      
    response.write "首页 上一页&nbsp;"
  else
    response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=1>首页</a>&nbsp;"
    response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=" & Page-1 & ">上一页</a>&nbsp;"
  end if
  if rs.pagecount-page<1 then
    response.write "下一页 尾页"
  else
    response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=" & (page+1) & ">"
    response.write "下一页</a> <a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page="&rs.pagecount&">尾页</a>"
  end if
   response.write "&nbsp;页次:<strong><font color=red>"&Page&"</font>/"&rs.pagecount&"</strong>页 "
    response.write "&nbsp;共<b><font color='#FF0000'>"&rs.recordcount&"</font></b>条记录 <b>"&rs.pagesize&"</b>条记录/页"
   response.write " 转到:<input type='text' name='page' size=3 maxlength=5 class=input value="&page&">"
   response.write " <input class=input type='submit'  value='Go'  name='cndok'></span></p>"     
%>
                </form></td>
              </tr>
<%
end if
rs.close
set rs=nothing
%>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
搜索更多相关主题的帖子: where 
2013-08-07 10:10
jsxhyj
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-8-7
收藏
得分:0 
这是我参考的网上的,但是我的我还是找不到错在什么地方,高手指点下吧


<!--#include file="conn.asp" -->
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from [表名]"
rs.open sql,conn,1,1

'-------只需要改动这3个地方-----------
    rs.pagesize = 10  '每页显示条数
    const Pname="p"   '当前页变量名
    UrlParam="&keyword=关键词&class=深圳"       'Url条件参数
'-------------------------------------

GETpage=trim(request(""&Pname&""))

if GETpage<>"" then
    page = int(GETpage)
    if page<1 then page = 1
    if page>rs.pagecount then page = rs.pagecount
else
    page = 1
end if

    rs.absolutepage = page '设置当前页等于page

for i = 0 to rs.pagesize -1     '循环显示数据
    if rs.eof then exit for     '如果到记录集末尾则退出for循环

    response.write(rs("lid")&"<br>")

    rs.movenext         '记录集下移一行
next
%>


<%'------------------------------------------------------
call FenYe(page,rs.pagecount,rs.pagesize,pname,UrlParam) '调用函数
'------------------------------------------------------%>


<%
function FenYe(Page,MaxCount,Psize,Pname,UrlParam)  'Page为当前点击页,MaxCount为记录集总条数,Psize为每页显示条数,Pname为当前页变量名,UrlParam为Url参数

    Page=Cint(Page)

'输出首页 上一页
    if Page<2 then
        response.write "首页"
        response.write "上一页"
    else
        response.write "<a href =?"&Pname&"=1"&UrlParam&">首页</a> "
        response.write "<a href =?"&Pname&"="&Page-1&UrlParam&">上一页</a> "
    end if

'输出数字分页部分,如果不需要数字分页,可删掉
    if Page>Psize-1 and MaxCount >Psize then
        if (Page+int((Psize-1)/2))>MaxCount then
            PageNow = MaxCount - Psize+1
        else
            PageNow = Page - int((Psize-1)/2)
        end if
            for i = 1 to Psize
            response.write "<a href=?"&Pname&"="&PageNow&UrlParam&">"&PageNow&"</a> "
            PageNow = PageNow + 1
        next
    else
        if MaxCount < Psize then
        for i = 1 to MaxCount
        response.write "<a href=?"&Pname&"="&i&UrlParam&">"&i&"</a> "
        next
        else
        for i = 1 to Psize
        response.write "<a href=?"&Pname&"="&i&UrlParam&">"&i&"</a> "
        next
        end if
    end if

'输出下一页 尾页
    if Page>=MaxCount then
        response.write "下一页 "
        response.write "尾页"
    else
        response.write "<a href = ?"&Pname&"="&Page+1&UrlParam&">下一页</a> "
        response.write "<a href = ?"&Pname&"="&MaxCount&UrlParam&">尾页</a>"
    end if
end function
%>
2013-08-07 21:52
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11771
专家分:43421
注 册:2006-5-13
收藏
得分:14 
将下一页代码中的括号删除试试。
if rs.pagecount-page<1 then
    response.write "下一页 尾页"
  else
    response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=" & (page+1) & ">"
    response.write "下一页</a> <a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page="&rs.pagecount&">尾页</a>"
  end if

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2013-08-09 07:13
jsxhyj
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-8-7
收藏
得分:0 
修改好了,红色的部分是修改的地方。
 <%if Page<2 then      
    response.write "首页 上一页&nbsp;"
  else
    'response.write "<a href=news.asp?BigClass="&BigClass&"&SmallClass="&SmallClass&"&page=1>首页</a>&nbsp;"
    response.write "<a href=news.asp?BigClass="&BigClass&"&page=1>首页</a>&nbsp;"
    'response.write "<a href=news.asp?page=" & Page-1 & "&BigClass="&BigClass&"&SmallClass="&SmallClass&">上一页</a>&nbsp;"
    response.write "<a href=news.asp?page=" & Page-1 & "&BigClass="&BigClass&">上一页</a>&nbsp;"
  end if
  if rs.pagecount-page<1 then
    response.write "下一页 尾页"
  else
    'response.write "<a href=news.asp?page="&int(page)+1&"&BigClass="&BigClass&"&SmallClass="&SmallClass&">"
    response.write "<a href=news.asp?page="&int(page)+1&"&BigClass="&BigClass&">"
    'response.write "下一页</a> <a href=news.asp?page="&rs.pagecount&"&BigClass="&BigClass&"&SmallClass="&SmallClass&">尾页</a>"
    response.write "下一页</a> <a href=news.asp?page="&rs.pagecount&"&BigClass="&BigClass&">尾页</a>"
  end if
2013-08-10 11:32
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:400
帖 子:11771
专家分:43421
注 册:2006-5-13
收藏
得分:0 
似乎“下一页”前面的int()函数还可以省略掉,因为在这里不可能会出现非整数,求整的函数是多余的。

活到老,学到老!http://www.(该域名已经被ISP盗卖了)E-mail:hu-jj@
2013-08-11 08:10
快速回复:分页就是会错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019445 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved