六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

用ASP做一個分頁程序

[摘要]請看以下實現ASP分頁程序的代碼: $#@60;anguage="vbscript" dim conn dim connstr dim totalPut dim CurrentPage dim TotalPages dim i,j dim sql dim rs on error...
請看以下實現ASP分頁程序的代碼:

$#@60;anguage="vbscript"

dim conn

dim connstr

dim totalPut

dim CurrentPage

dim TotalPages

dim i,j

dim sql

dim rs

on error resume next

打開數據庫

connstr="DBQ="+server.mappath("book.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

set conn=server.createobject("ADODB.CONNECTION")

conn.open connstr

set rs=server.createobject("adodb.recordset")

定義每頁文章顯示數

const MaxPerPage=18

if not isempty(request("page")) then

currentPage=cint(request("page"))

else

currentPage=1

end if

sql="select * from learning order by articleid desc"

Set rs= Server.CreateObject("ADODB.Recordset")

rs.open sql,conn,1,1

if rs.eof and rs.bof then

response.write "$#@60;p align=center$#@62; 還 沒 有 任 何 文 章$#@60;/p$#@62;"

else

數據庫中文章數totalput

totalPut=rs.recordcount

if currentpage$#@60;1 then

currentpage=1

end if

統計總頁數currentpage

if (currentpage-1)*MaxPerPage$#@62;totalput then

if (totalPut mod MaxPerPage)=0 then

currentpage= totalPut \ MaxPerPage

else

currentpage= totalPut \ MaxPerPage + 1

end if

end if

if currentPage=1 then

showpage totalput,MaxPerPage,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

else

if (currentPage-1)*MaxPerPage$#@60;totalPut then

rs.move (currentPage-1)*MaxPerPage

dim b mark

bookmark=rs.bookmark

showpage totalput,MaxPerPage,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

else

currentPage=1

showpage totalput,MaxPerPage,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

end if

end if

rs.close

end if

set rs=nothing

conn.close

set conn=nothing

sub showContent

dim i

i=0

do while not rs.eof

$#@62;

選擇顯示數據庫內容

$#@60;a href="openarticle.asp?id=$#@60;=rs("articleid")$#@62;"$#@62;$#@60;=rs("title")$#@62;$#@60;/a$#@62;[點擊:$#@60;=rs("hits")$#@62;]$#@60;br$#@62;

$#@60;

當顯示記錄大于maxperpage時結束這頁

i=i+1

if i$#@62;=MaxPerPage then exit do

rs.movenext

loop

end sub

function showpage(totalnumber,maxperpage,filename)

求出當每頁18篇文章時總共的頁數

dim n

if totalnumber mod maxperpage=0 then

n= totalnumber \ maxperpage

else

n= totalnumber \ maxperpage+1

end if

response.write "$#@60;form method=Post action="&filename&"$#@62;"

response.write "$#@60;p align=center$#@62;$#@60;font color=#000080$#@62;$#@62;$#@62;分頁$#@60;/font$#@62; "

顯示頁數鏈接的條件

if CurrentPage$#@60;2 then

response.write "$#@60;font color=#000080$#@62;首頁 上一頁$#@60;/font$#@62; "

else

response.write "$#@60;a href="&filename&"?page=1&$#@62;首頁$#@60;/a$#@62; "

response.write "$#@60;a href="&filename&"?page="&CurrentPage-1&"$#@62;上一頁$#@60;/a$#@62; "

end if

if n-currentpage$#@60;1 then

response.write "$#@60;font color=#000080$#@62;下一頁 尾頁$#@60;/font$#@62;"

else

response.write "$#@60;a href="&filename&"?page="&(CurrentPage+1)

response.write "$#@62;下一頁$#@60;/a$#@62; $#@60;a href="&filename&"?page="&n&"$#@62;尾頁$#@60;/a$#@62;"

end ifc

response.write "$#@60;font color=#000080$#@62; 頁次:$#@60;/font$#@62;$#@60;strong$#@62;$#@60;font color=red$#@62;"&CurrentPage&"$#@60;/font$#@62;$#@60;font color=#000080$#@62;/"&n&"$#@60;/strong$#@62;頁$#@60;/font$#@62;"

response.write "$#@60;font color=#000080$#@62; 共$#@60;b$#@62;"&totalnumber&"$#@60;/b$#@62;篇文章 $#@60;b$#@62;"&maxperpage&"$#@60;/b$#@62;篇文章/頁$#@60;/font$#@62;"

response.write " $#@60;font color=#000080$#@62;轉到:$#@60;/font$#@62;$#@60;input type=text name=page size=4 maxlength=10 class=smallInput value="¤tpage&"$#@62;"

response.write "$#@60;input class=buttonface type=submit value= Goto name=cndok$#@62;$#@60;/span$#@62;$#@60;/p$#@62;$#@60;/form$#@62;"

end function

$#@62;

  以上代碼很簡單的就實現了ASP網頁的多種分頁功能,不論是對瀏覽者還是管理者都能很方便的瀏覽和管理,我只在相關部分作了一些解釋,象這個ASP程序還必須有數據庫的支持才可以,關于數據庫的問題我就不詳述了,具體的實例大家可以看看我的主頁(http://aasp.yeah.net)上的文章管理程序,另外還有具體的程序下載!



主站蜘蛛池模板: 欧美亚洲综合另类 | 欧美一卡二卡三卡四卡 | 天堂网在线视频 | 欧美亚洲一级片 | 天堂资源在线8 | 一级做a爰片性色毛片小说 一级做a爰片性色毛片思念网 | 日韩三级精品 | 色日韩在线 | 欧美视频一二三区 | 五月婷婷欧美 | 日本天堂网在线观看 | 天堂bt| 四房婷婷 | 日韩一级免费毛片 | 日韩一级淫片 | 欧美在线网 | 四虎精品永久在线 | 特级黄色淫片 | 羞羞漫画在线阅读页面漫画入口页面弹窗无限 | 亚洲婷婷六月 | 日韩在线观看网址 | 午夜精品aaa国产福利 | 亚洲一区二区免费看 | 四虎影视国产在线观看精品 | 日产精品卡二卡三卡四卡乱码视频 | 亚洲成a人片在线观看导航 亚洲成a人片在线观看播放 | 日韩免费片 | 青青在线免费观看 | 青青青视频在线播放视频 | 亚洲成人福利在线 | 日本高清一本视频 | 色婷婷中文字幕在线一区天堂 | 骚妇毛片 | 日本成人在线免费观看 | 一级做a爰在线就看 | 天天爽夜夜爽天天做夜夜做 | 婷婷丁香四月 | 日韩视频网址 | 日韩精品一区二区在线观看 | 欧美性活一级视频 | 偷拍第一页 |