首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

应用封装好的分页代码,没有信息输出,也不报错,这是什么情况

2013-08-01 
使用封装好的分页代码,没有信息输出,也不报错,这是什么情况分页代码是用的追梦阳光贴吧里面的,数据库中也

使用封装好的分页代码,没有信息输出,也不报错,这是什么情况
分页代码是用的追梦阳光贴吧里面的,数据库中也有信息,但是在调用的时候没有信息出来,也没有报错,这是什么情况???

<!--#include file="Data/conn.asp" -->
<!--#include file="Include/function.asp"-->
<!--#include file="Include/getfunction.asp"-->
<%
PageShowSize = 5            '每页显示多少个页
MyPageSize   = 1        '每页显示多少条
If Not IsNumeric(Request("Curpage")) Or IsEmpty(Request("Curpage")) Or Request("Curpage") <=0 Then
MyPage=1
Else
MyPage=Int(Abs(Request("Curpage")))
End if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>首页</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript">
window.onload = function(){
    var aLink = document.getElementById("nav").getElementsByTagName("li");
    var oMask = document.getElementById("mask");
    for(var i=0; i<aLink.length; i++){
        aLink[i].onmouseover = function(){
            startMove(oMask, this.offsetLeft);
        }
    }
}

var iSpeed = 0;
var left = 0;
function startMove(obj, iTarget){
    clearInterval(obj.timer);
    obj.timer = setInterval(function(){
        iSpeed += (iTarget-obj.offsetLeft)/5;
        iSpeed *= 0.7;
        left += iSpeed;
        if(Math.abs(iSpeed)<1 && Math.abs(iTarget-left)<1){
            clearInterval(obj.timer);
            obj.style.left = iTarget+"px";
        }else{
            obj.style.left = left+"px";
        }
    }, 30);


}
</script>

</head>
<body>
<!--#include file="top.asp"-->
<div class="wrap clearfix">
<div class="main">
        <div class="main-list">
<%
newslist="<div class=""list-item"">"
set adoRS=server.createobject("adodb.recordset")
sql="select * from VipInfo where infotype='招聘信息' and checkstate=1"
adoRS.open sql,conn,1,1
SQLQueryNums=SQLQueryNums+1
If adoRS.eof And adoRS.bof Then
newslist=newslist & "<CENTER>暂时没有资讯,请稍后阅读</CENTER>"
Else
adoRS.PageSize     = MyPageSize
MaxPages           = adoRS.PageCount
adoRS.absolutepage = MyPage
Totalcount         = adoRS.RecordCount
for i=1 to adoRS.PageSize
If not adoRS.eof Then 
newslist=newslist&"<h2>"&adoRS("title")&"</h2><p>"&adoRS("content")&"</p><small>联系人:"&adoRS("linkman")&"</small><small>联系电话:"&adoRS("tel")&"</small><small>"&adoRS("sdate")&"</small></div>"
adoRS.MoveNext
end if
Next
newslist=newslist&"</div><div class=""pages"">"&viewpage(Totalcount,MyPageSize,PageShowSize,MyPage,"","当前总数:","index.asp")&"</div>"
End If 
adoRS.close
Set adoRS=Nothing
%>
</div>
<div class="right">
<div class="title-bar">
<h2>推荐信息</h2>
<ul>
<%call NewsFlag(5,20)%>
</ul>
</div>
</div>

</div>
<!--#include file="footer.asp"-->
</body>
</html>




'*************************************
'分页代码viewpage(总记录,显示记录数,显示页数,当前页,传替参数,总数说明,当前页面名称)
'p_c:总记录
'p_n:显示记录数
'p_x:显示页数
'p_p:当前页
'Dreamsun_cls:传替参数
'p_z:总数说明
'showfile:当前页面名称
'*************************************
Function viewpage(p_c,p_n,p_x,p_p,Dreamsun_cls,p_z,showfile)
dim p_k,p_y,p_p2,p_p3,p_m
'计算页数相关
if p_c/p_n = int(p_c/p_n) then 
p_y=int(p_c/p_n)
else
p_y=int(p_c/p_n)+1
end if
if p_p>p_y then p_p=p_y  
p_p2= int(p_p/p_x)
if p_p/p_x>p_p2 then p_p2=p_p2+1
p_k=p_p2*p_x
if p_k>p_y then p_k=p_y
If Dreamsun_cls<>"" And Left(Dreamsun_cls,1)<>"&" Then Dreamsun_cls="&"&Dreamsun_cls


viewpage=viewpage& "<div class=""list-page"">"
if p_p=1 then
viewpage=viewpage& "<a>首页</a>"
viewpage=viewpage& "<a>上一页</a>"
Else
viewpage=viewpage& "<a href='"&showfile&"?CurPage=1" & Dreamsun_cls&"'>首页</a> "
viewpage=viewpage& "<a href='"&showfile&"?CurPage="& p_p-1 & Dreamsun_cls&"'>上一页</a> "
end If
if p_x/2 = int(p_x/2) then 
nn=int(p_x/2)
else
nn=int(p_x/2)+1
end if
if p_p<=nn then
pi=1
ri=nn*2+1
else
pi=p_p - nn
ri=p_p + nn
end if

if p_y-p_p<=nn then
pi=p_y-(nn*2)
if pi<0 then pi=1
ri=p_y
end If

if pi=0 then pi=1

For p_m =pi To ri
if p_m=p_p then
viewpage=viewpage& "<strong>"& p_m &"</strong>"
else
viewpage=viewpage& "<a href='"&showfile&"?CurPage="& p_m & Dreamsun_cls&"'>"& p_m &"</a>"
end if
Next
if p_p < p_y then
viewpage=viewpage& "<a href='"&showfile&"?CurPage="&p_p+1 & Dreamsun_cls&"'>下一页</a>"
viewpage=viewpage& "<a href='"&showfile&"?CurPage="&p_y & Dreamsun_cls&"'>尾页</a>"
Else
viewpage=viewpage& "<a>下一页</a>"
viewpage=viewpage& "<a>尾页</a>"
end if
'viewpage=viewpage& "<input type=""text"" name=""custompage"" size=""3"" onkeydown=""if(event.keyCode==13) {window.location='"&showfile&"?abc=1"&Dreamsun_cls&"&amp;CurPage='+this.value; return false;}""/></div>"& vbCrLf
 viewpage=viewpage& "</div>"& vbCrLf
End Function

分页
[解决办法]
试试我写的吧

<%

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


'函数名:PasteURL
'作  用:向地址中加入 ? 或 &
'参  数:strUrl  ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function PasteURL(strUrl)
if strUrl="" then
PasteURL=""
exit function
end if
'如果传入的URL末尾不是"?",有两种情况:
'1.无“?”,此时需加入一个“?”
'2. 有“?”再判断有无“&”
if InStr(strUrl,"?")<len(strUrl) then 
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then 
PasteURL=strUrl & "&"
else
PasteURL=strUrl
end if
else
PasteURL=strUrl & "?"
end if
else
PasteURL=strUrl
end if
end function

'***********************************************
'过程名:ShowPage
'作  用:显示“上一页 下一页”等信息
'参  数:sDesURL  ----链接地址,可以是一个文件名,也可以是一个有一些参数所URL
'       nTotalNumber ----总数量
'       nMaxPerPage  ----每页数量
'       nCurrentPage ----当前页
'       nBlock              ----数字页码可示段的数量
'       cPageStyle      ----当前页码的CSS样式
'       bSymbol          ----是否显示标记位
'***********************************************
sub ShowPage(sDesURL, nTotalNumber, nMaxPerPage, nCurrentPage,nBlock,cPageStyle,bSymbol)
dim n, i,strTemp,strUrl,strStyle,poutStr
'计算页数
if nTotalNumber mod nMaxPerPage=0 then
    n= nTotalNumber \ nMaxPerPage
  else
    n= nTotalNumber \ nMaxPerPage+1
  end if
  '判断nCurrentPage
  if nCurrentPage < 1 then
  nCurrentPage = 1
  elseif nCurrentPage > n then
  nCurrentPage = n
  end if
        strStyle=cPageStyle
        If strStyle="" then strStyle="current"
'根据输入的sDesURL向它加入?或&
strUrl=PasteURL(sDesURL)
        poutStr="<dl>"
  if nCurrentPage<2 then
    poutStr=poutStr&"<dt>INDEX</dt> <dt>PREV</dt>"
  else
    poutStr=poutStr& "<dt><a href='" & strUrl & "page=1'>INDEX</a></dt>"


    poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & (nCurrentPage-1) & "'>PREV</a></dt>"
  end if
        'mm页码标量
        'limax数字页码的可示上限
        'lilow数字页码的可示下限
        'lisymbol上一个可示段的上限
        'outStr数字页码的缓存字符串
        Dim mm,limax,lilow,lisymbol,outStr

        If n>1 then
                outStr= "<dd><ul>"
                '数字页码的可示上限
                if nCurrentPage Mod nBlock >0 then
                        limax=((nCurrentPage \ nBlock) * nBlock) + nBlock
                else
                        limax=(nCurrentPage \ nBlock) * nBlock
                end if
                '数字页码的可示下限
                lilow=limax - nBlock+1
                if limax>n then limax=n
                '显示上一个标记位
                if bSymbol then
                         if lilow mod  nBlock>0 And lilow>1 then
                                    lisymbol=lilow - 1 - nBlock
                                    if lisymbol=0 then lisymbol=1


                                    outStr=outStr& "<li><a href='" & strUrl & "page="&lisymbol&"'>"&lisymbol&"</a></li><li> ... </li>"
                         end if
                end if
                '打印数字页码
                for mm=lilow to limax
                            outStr=outStr& "<li>"
                            if mm=nCurrentPage then
                                       outStr=outStr& "<span class='"&strStyle&"'>"&mm&"</span>"
                            else
                                       outStr=outStr& "<a href='" & strUrl & "page="&mm&"'>"&mm&"</a>"
                            end if
                            outStr=outStr& "</li>"
                next
                '显示最后一个标记位
                if bSymbol then
                           if limax<n then


                                        outStr=outStr& "<li> ... </li><li><a href='" & strUrl & "page="&n&"'>"&n&"</a></li>"
                           end if
                end if
                outStr=outStr& "</ul></dd>"
                poutStr=poutStr&""&outStr
        End If
  if n-nCurrentPage<1 then
    poutStr=poutStr& "<dt>NEXT</dt><dt>END</dt>"
  else
    poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & (nCurrentPage+1) & "'>NEXT</a></dt>"
    poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & n & "'>END</a></dt>"
  end if
        poutStr=poutStr&"</dl><label>showing "&((nCurrentPage-1)*nMaxPerPage)+1&" - "
        if nCurrentPage*nMaxPerPage> nTotalNumber then
                poutStr=poutStr&""&nTotalNumber
        else
                poutStr=poutStr&""&nCurrentPage*nMaxPerPage
        end if
        poutStr=poutStr&" of "&nTotalNumber&"</label>"
        Response.Write poutStr
end sub
%>



调用示例:


                        set strRs=Server.CreateObject("ADODB.Recordset")
                        strRs.Open strSQL,conn,1,1
                        
                        If NOT strRs.EOF then 
'分页代码
                Dim CurrentPage
                Dim jumpPage:jumpPage="ask.asp"
If Not IsEmpty(Request.QueryString("page")) then
CurrentPage=CInt(Request.QueryString("page"))
Else
CurrentPage=1
End If

strRs.PageSize=5
If CurrentPage<1 then CurrentPage=1
If CurrentPage>strRs.PageCount then CurrentPage=strRs.PageCount
If Not strRs.EOF Then
strRs.AbsolutePage=CurrentPage
End If
Dim I:I=0
'分页代码
                               do while NOT strRs.EOF%>
                         <div class="forumitem"><dl><dt><%=strRs("reviewn")%></dt><dd><a href="displayask.asp?record=<%=strRs("ID")%>" target="_blank">View</a> / <a href="newreview.asp?topic=<%=Server.URLEncode(strRs("topic"))%>&record=<%=strRs("ID")%>">Review</a></dd></dl><label><span><a href="displayask.asp?record=<%=strRs("ID")%>" target="_blank"><%If CBool(strRs("isfinish")) then%><img src="../image/trac/finish.png" border="0" /><%End If%><%=htmlencodestr(strRs("topic"))%></a></span><%=Left(filterEditor(Trim(strRs("content"))),200)%></label></div> 
                                             <%
'分页代码
                I=I+1


If I>=strRs.PageSize then Exit Do    
'分页代码 
                                             strRs.MoveNext
                               Loop
                        Else
                              Response.Write "no resultset"
                        End If%>                                                                                                                                           
                   </div>                       
                   <div id="pagepanel"><%call showpage(jumpPage,strRs.RecordCount,strRs.PageSize,CurrentPage,5,"current",true)%></div>   
                   <%
                        strRs.Close
                        set strRs=Nothing
                        CloseDatabase              


                   %>                   

热点排行