国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

ASP分頁函數(shù)、分頁導航

2019-11-17 04:13:09
字體:
來源:轉載
供稿:網(wǎng)友
程序代碼
<%
'//分頁函數(shù)
    '//psize:每頁顯示的數(shù)據(jù)數(shù)
    '//pindex:當前頁碼
    '//tbName:表名
    '//keyIndex:根據(jù)什么字段分頁,一般是自增長類型(access數(shù)據(jù)庫的自動編號)
    '//where:查詢條件
    '//order:排序條件,缺省為" order by " &keyIndex &" desc"
    '//總記錄數(shù)與總頁數(shù)可從返回的結果集中直接獲取,字段datacount存儲總記錄數(shù),字段pagecount存儲總頁數(shù)
    PRivate pindex,datacount,pages
    'datacount = 0
    'pages = 1
    public function changePage(psize,tbName,keyIndex,where,order)
        dim sqlstring
        pindex = Trim(Request.QueryString("page"))
        if not isnumeric(psize) or psize="" then psize=1'//每頁顯示的數(shù)據(jù)數(shù)
        if not isnumeric(pindex) or pindex="" then pindex=1'//當前頁碼
        if order="" then order=" order by " & keyIndex & " desc"
        '//獲取總數(shù)據(jù)數(shù)
        'dim datacount,pages
        set rs=conn.execute("select count(*) as datacount from " & tbName & " where 1=1 " & where)
        datacount = rs("datacount")'//總記錄數(shù)
        rs.close
        set rs=nothing
        '//計算總頁數(shù)
        if (datacount mod psize)=0 then
            pages=datacount / psize
        else
            pages=datacount / psize + 1
        end if
        '//
        if cint(pindex)>pages then pindex=pages
        '拼接sql字符串
        if pindex<=1 then
            sqlstring="select top " & psize & " *," & datacount & " as datacount," & pages & " as pagecount from " &_
                        tbName & " where 1=1 " & where & " " & order
        else
            sqlstring="select top " & psize & " *," & datacount & " as datacount," & pages & " as pagecount from " &_
                        tbName & " where 1=1 and " & keyIndex & " not in(select top " & (pindex-1)*psize & " " & keyIndex & " from " &_
                        tbName & " where 1=1 " & where & " " & order & ") " & where & " " & order
        end if
        'Response.Write(sqlstring)
        set changePage=conn.execute(sqlstring)
    end function
    '//分頁導航
    '//fileName:文件名/當前頁面的話,可以留空
    '//argString:分頁參數(shù)例如classid=1&tid=16,分頁必須的參數(shù)page不必填寫
    '//pindex:當前頁碼
    '//datacount:總記錄數(shù)
    '//pages:總頁數(shù)
    '//showMsg:是否顯示分頁信息,參數(shù)為true/false
    '//showText:是否顯示首頁、上頁、下頁、末頁的導航,參數(shù)為true/false
    '//showNumber:是否顯示數(shù)字分頁導航,參數(shù)為true/false
    'public function pageLink(fileName,argString,pindex,datacount,pages,showMsg,showText,showNumber)
    public function pageLink(fileName,argString,showMsg,showText,showNumber)
        '//
        if argString<>"" then argString = argString & "&"
        if not showText and not showNumber then showText=true
        '//
        if showMsg then
            Response.Write("[")
            Response.Write("第 <span style='color:red;'>" & pindex & "</span> 頁")
            Response.Write("/分 <span style='color:red;'>" & pages & "</span> 頁")
            Response.Write("/總 <span style='color:red;'>" & datacount & "</span> 條記錄")
            Response.Write("] ")
        end if
        '//
        if showText then
            if pindex>1 then
                Response.Write("<a href='" & fileName & "?" & argString & "page=1'>[首頁]</a>")
                Response.Write(" ")
                Response.Write("<a href='" & fileName & "?" & argString & "page=" & pindex - 1 & "'>[上頁]</a>")
            else
                Response.Write("[首頁]")
                Response.Write(" ")
                Response.Write("[上頁]")
            end if
            Response.Write(" ")
            if pindex<pages then
                Response.Write("<a href='" & fileName & "?" & argString & "page=" & pindex + 1 & "'>[下頁]</a>")
                Response.Write(" ")
                Response.Write("<a href='" & fileName & "?" & argString & "page=" & pages & "'>[末頁]</a>")
            else
                Response.Write("[下頁]")
                Response.Write(" ")
                Response.Write("[末頁]")
            end if
        end if
        '//
        if showNumber then
            Response.Write("      ")
            for i = 4 to 1 step -1
                if (pindex - i)>0 then
                    Response.Write("<a href='" & fileName & "?" & argString & "page=" & pindex - i & "'>" & pindex - i & "</a>")
                    Response.Write(" ")
                end if
            next
            '//
            Response.Write("<span style='color:red;'>" & pindex & "</span>")
            '//
            for i = 1 to 4
                if (pindex + i)<=pages then
                    Response.Write(" ")
                    Response.Write("<a href='" & fileName & "?" & argString & "page=" & pindex + i & "'>" & pindex + i & "</a>")
                end if
            next
            '//
        end if
        '//
    end function
%>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 华坪县| 吉木乃县| 阿勒泰市| 原平市| 长岭县| 新建县| 凤城市| 民勤县| 宁南县| 苏尼特左旗| 山东| 社旗县| 郁南县| 牡丹江市| 邢台县| 湛江市| 黔东| 开阳县| 扶绥县| 尼玛县| 桐梓县| 南康市| 兴化市| 通州区| 儋州市| 乌拉特中旗| 勃利县| 青河县| 延川县| 阳东县| 南康市| 聂荣县| 昌都县| 英超| 巴林左旗| 丰镇市| 德江县| 磴口县| 江山市| 丹江口市| 民丰县|