asp快速分頁(yè)代碼_ASP教程
推薦:Asp文件操作函數(shù)集% '===============asp 文件操作函數(shù)集1.0版本========================= ' 整理作者: 張輝 ' 程序員代號(hào):WJ008 ' 整理時(shí)間:2008年 6 月 1 日 ' 關(guān)注地址:www.wj008.net ' 所有函數(shù)使用的文件地址 全部使用絕對(duì)地址 '============================================
<%@ language = "vbscript" codepage = 936%>
<%
option explicit '強(qiáng)制定義變量
dim idcount'記錄總數(shù)
dim pages'每頁(yè)條數(shù)
dim pagec'總頁(yè)數(shù)
dim page'頁(yè)碼
dim pagenc '每頁(yè)顯示的分頁(yè)頁(yè)碼數(shù)量=pagenc*2+1
pagenc=2
dim pagenmax '每頁(yè)顯示的分頁(yè)的最大頁(yè)碼
dim pagenmin '每頁(yè)顯示的分頁(yè)的最小頁(yè)碼
page=clng(request("page"))
dim start'程序開(kāi)始的時(shí)間
dim endt'程序結(jié)束的時(shí)間
dim datafrom'數(shù)據(jù)表名
datafrom="table1"
dim conn,rs
dim datapath '數(shù)據(jù)庫(kù)路經(jīng)
dim sqlid'本頁(yè)需要用到的id
dim myself'本頁(yè)地址
myself = request.servervariables("path_info")
dim sql'sql語(yǔ)句
dim taxis'排序的語(yǔ)句
'taxis="order by id asc" '正排序
taxis="order by id desc" '倒排序
dim i'用于循環(huán)的整數(shù)
start=timer()
datapath="db.mdb"'數(shù)據(jù)庫(kù)
pages=30
'連接打開(kāi)數(shù)據(jù)庫(kù)
dim db
db="db.mdb" '定義數(shù)據(jù)庫(kù)路徑及名稱(chēng)
set conn = server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath(db)
if err.number <> 0 then
response.write "數(shù)據(jù)庫(kù)鏈接出錯(cuò)!"
response.end()
end if
'獲取記錄總數(shù)
sql="select count(id) as idcount from ["& datafrom &"]"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
idcount=rs("idcount")'獲取記錄總數(shù)
if(idcount>0) then'如果記錄總數(shù)=0,則不處理
if(idcount mod pages=0)then'如果記錄總數(shù)除以每頁(yè)條數(shù)有余數(shù),則=記錄總數(shù)/每頁(yè)條數(shù)+1
pagec=int(idcount/pages)'獲取總頁(yè)數(shù)
else
pagec=int(idcount/pages)+1'獲取總頁(yè)數(shù)
end if
'獲取本頁(yè)需要用到的id============================================
'讀取所有記錄的id數(shù)值,因?yàn)橹挥衖d所以速度很快
sql="select id from ["& datafrom &"] " & taxis
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize = pages '每頁(yè)顯示記錄數(shù)
if page < 1 then page = 1
if page > pagec then page = pagec
if pagec > 0 then rs.absolutepage = page
for i=1 to rs.pagesize
if rs.eof then exit for
if(i=1)then
sqlid=rs("id")
else
sqlid=sqlid &","&rs("id")
end if
rs.movenext
next
'獲取本頁(yè)需要用到的id結(jié)束============================================
end if
%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>快速分頁(yè)</title>
<link rel="stylesheet" href="page.css" type="text/css">
</head>
<body bgcolor="#f2f2f2" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellpadding="20" cellspacing="0">
<tr>
<td valign="middle"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
<tr>
<td valign="top" bgcolor="#ffffff"><br> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="zw">
<tr>
<td><strong><font color="#ff6600">快速分頁(yè)</font></strong></td>
</tr>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="cccccc" class="zw">
<tr align="center" bgcolor="#9fcb07">
<td width="9%"><strong>ID</strong></td>
<td width="37%"><strong>主題</strong></td>
<td width="33%"><strong>內(nèi)容</strong></td>
<td width="21%"><strong>時(shí)間</strong></td>
</tr>
<%
if(idcount>0 and sqlid<>"") then'如果記錄總數(shù)=0,則不處理
'用in刷選本頁(yè)所語(yǔ)言的數(shù)據(jù),僅讀取本頁(yè)所需的數(shù)據(jù),所以速度快
sql="select [id],[aaaa],[bbbb],[cccc] from ["& datafrom &"] where id in("& sqlid &") "&taxis
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
while(not rs.eof)'填充數(shù)據(jù)到表格
%>
<tr bgcolor="#ffffff">
<td align="center"><%=rs(0)%></td>
<td><%=rs(1)%></td>
<td><%=rs(2)%></td>
<td align="center"><%=rs(3)%></td>
</tr>
<%
rs.movenext
wend
%>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="zw">
<tr align="center">
<td align="left">共有<strong><font color="#ff6600"><%=idcount%></font></strong>條記錄,<strong><font color="#ff6600"><%=page%></font></strong>/<%=pagec%>,每頁(yè)<strong><font color="#ff6600"><%=pages%></font></strong>條。</td>
</tr>
</table>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="zw">
<tr align="center">
<td align="right">
<%
'設(shè)置分頁(yè)頁(yè)碼開(kāi)始===============================
pagenmin=page-pagenc'計(jì)算頁(yè)碼開(kāi)始值
pagenmax=page+pagenc'計(jì)算頁(yè)碼結(jié)束值
if(pagenmin<1) then'如果頁(yè)碼開(kāi)始值小于1則=1
pagenmin=1
end if
if(page>1) then'如果頁(yè)碼大于1則顯示(第一頁(yè))
response.write ("<a href='"& myself &"?page=1'><font color='#000000'>第一頁(yè)</font></a> ")
end if
if(pagenmin>1) then'如果頁(yè)碼開(kāi)始值大于1則顯示(更前)
response.write ("<a href='"& myself &"?page="& page-(pagenc*2+1) &"'><font color='#000000'>更前</font></a> ")
end if
if(pagenmax>pagec) then'如果頁(yè)碼結(jié)束值大于總頁(yè)數(shù),則=總頁(yè)數(shù)
pagenmax=pagec
end if
for i = pagenmin to pagenmax'循環(huán)輸出頁(yè)碼
if(i=page) then
response.write ("<font color='#ff6600'><strong>"& i &"</strong></font> ")
else
response.write ("[ <a href="& myself &"?page="& i &"><font color='#000000'>"& i &"</font></a> ] ")
end if
next
if(pagenmax<pagec) then'如果頁(yè)碼結(jié)束值小于總頁(yè)數(shù)則顯示(更后)
response.write ("<a href='"& myself &"?page="& page+(pagenc*2+1) &"'><font color='#000000'>更后</font></a> ")
end if
if(page<pagec) then'如果頁(yè)碼小于總頁(yè)數(shù)則顯示(最后頁(yè))
response.write ("<a href='"& myself &"?page="& pagec &"'><font color='#000000'>最后頁(yè)</font></a> ")
end if
'設(shè)置分頁(yè)頁(yè)碼結(jié)束===============================
%><script language="javascript">
<!--
function gopage() {
window.location.href="<%=myself%>?page="+ page.value;
}
//-->
</script>
轉(zhuǎn)到
<input name="page" type="text" value="<%=page%>" size="5">頁(yè)
<input type="button" name="submit" value="跳轉(zhuǎn)" ></td>
</tr>
</table>
<%
end if
%>
<br>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="zw">
<tr>
<td align="center">
<p>
<%
endt=timer()
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%=formatnumber((endt-start)*1000,3)%>毫秒 </p>
<p><a href="http://stone-stone.vip.sina.com/" target="_blank">STONE空間</a></p></td>
</tr>
</table>
<br></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
分享:ASP使用FCKEditor的設(shè)置技巧1、默認(rèn)語(yǔ)言 打開(kāi)fckconfig.js文件(相對(duì)FCKeditor文件夾,以下同),把自動(dòng)檢測(cè)語(yǔ)言改為不檢測(cè),把默認(rèn)語(yǔ)言改為簡(jiǎn)體中文: 程序代碼 FCKConfig.AutoDetectLanguage = false ; FCKConfig.DefaultLanguage = 'zh-cn' ; 2、字體列表 打開(kāi)fckconfig.js文件,在字體列表中
- asp FSO 讀寫(xiě)文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶(hù)真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過(guò)濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無(wú)組件分頁(yè)實(shí)現(xiàn)思路及代碼
ASP教程Rss訂閱編程教程搜索
ASP教程推薦
- 怎樣判斷遠(yuǎn)程圖片是否存在
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- 入門(mén):初學(xué)ASP動(dòng)態(tài)網(wǎng)頁(yè)制作常用錯(cuò)誤處理
- asp 讀取通過(guò)表單發(fā)送的post數(shù)據(jù)
- ASP實(shí)例 掛QQ的網(wǎng)頁(yè)源代碼ASP/PHP
- 解析ASP中腳本執(zhí)行順序
- 揭秘escape解決AJAX中文亂碼的簡(jiǎn)單方法
- 從ASP遷移至ASP --最初的考慮(二)
- ASP組件AspJpeg(加水印)生成縮略圖等使用方法
- 怎樣用ASP程序判斷一個(gè)盤(pán)上是否有文件
- 相關(guān)鏈接:
- 教程說(shuō)明:
ASP教程-asp快速分頁(yè)代碼
。