回覆列表
  • 1 # 使用者6847486145697

    <%

    dim articleStr,CurrentPage,Maxlen,totalLen,i,j,n

    articleStr = rs("content") "從資料庫中讀取的內容

    Maxlen = 1000 "初始化每頁顯示的字數

    totalLen = len(articleStr)

    if totalLen mod Maxlen = 0 then

    pageCounts = fix(totalLen/Maxlen)

    else

    pageCounts = fix(totalLen/Maxlen)+1

    end if

    CurrentPage = Request("page")

    if CurrentPage = "" then

    CurrentPage = 1

    end if

    if Clng(CurrentPage) > pageCounts then CurrentPage = pageCounts

    i = (CurrentPage-1)*Maxlen+1

    j = Maxlen

    Response.write mid(articleStr,i,j)&"<br>" "內容顯示

    "分頁程式碼開始

    Response.write "總頁數:"&pageCounts&" "

    if CurrentPage < 2 then

    Response.write "首頁 上一頁"

    else

    end if

    if CurrentPage > 3 then Response.write"..."

    for n = CurrentPage - 3 to CurrentPage + 3

    if n > 0 and Clng(n) <= pageCounts then

    end if

    next

    if CurrentPage + 3 < pageCounts then Response.write"..."

    if Clng(CuttentPage) = pageCounts then

    Response.write "下一頁 末頁"

    else

    end if

    %>

    把以上程式碼儲存成某個asp檔案,然後在內容頁裡透過include呼叫就可以了。具體設定可以自己改,有註釋

  • 中秋節和大豐收的關聯?
  • 七武海制度被廢除以後,海軍靠什麼制衡四皇,僅僅是三大將麼?