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

首頁 > 編程 > ASP > 正文

asp快速分頁代碼_ASP教程

2024-05-04 11:04:44
字體:
來源:轉載
供稿:網友

推薦:

 <%@ language = "vbscript" codepage = 936%>

<%
option explicit '強制定義變量
dim idcount'記錄總數
dim pages'每頁條數
dim pagec'總頁數
dim page'頁碼
dim pagenc '每頁顯示的分頁頁碼數量=pagenc*2+1
pagenc=2
dim pagenmax '每頁顯示的分頁的最大頁碼
dim pagenmin '每頁顯示的分頁的最小頁碼
page=clng(request("page"))
dim start'程序開始的時間
dim endt'程序結束的時間
dim datafrom'數據表名
datafrom="table1"
dim conn,rs
dim datapath '數據庫路經
dim sqlid'本頁需要用到的id
dim myself'本頁地址
myself = request.servervariables("path_info")
dim sql'sql語句
dim taxis'排序的語句
'taxis="order by id asc" '正排序
taxis="order by id desc" '倒排序
dim i'用于循環(huán)的整數
start=timer()
datapath="db.mdb"'數據庫
pages=30

'連接打開數據庫
dim db
db="db.mdb"     '定義數據庫路徑及名稱
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 "數據庫鏈接出錯!"
   response.end()
end if

'獲取記錄總數
sql="select count(id) as idcount from ["& datafrom &"]"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,0,1
idcount=rs("idcount")'獲取記錄總數

if(idcount>0) then'如果記錄總數=0,則不處理
 if(idcount mod pages=0)then'如果記錄總數除以每頁條數有余數,則=記錄總數/每頁條數+1
  pagec=int(idcount/pages)'獲取總頁數
 else
  pagec=int(idcount/pages)+1'獲取總頁數
 end if

 '獲取本頁需要用到的id============================================
 '讀取所有記錄的id數值,因為只有id所以速度很快
 sql="select id from ["& datafrom &"] " & taxis
 set rs=server.createobject("adodb.recordset")
 rs.open sql,conn,1,1

    rs.pagesize = pages '每頁顯示記錄數
    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
 '獲取本頁需要用到的id結束============================================
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>快速分頁</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">快速分頁</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>內容</strong></td>
              <td width="21%"><strong>時間</strong></td>
            </tr>
<%
if(idcount>0 and sqlid<>"") then'如果記錄總數=0,則不處理
 '用in刷選本頁所語言的數據,僅讀取本頁所需的數據,所以速度快
 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)'填充數據到表格
 %>
      <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%>,每頁<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">
        <%
 '設置分頁頁碼開始===============================
 pagenmin=page-pagenc'計算頁碼開始值
 pagenmax=page+pagenc'計算頁碼結束值
 if(pagenmin<1) then'如果頁碼開始值小于1則=1
     pagenmin=1
 end if

 if(page>1) then'如果頁碼大于1則顯示(第一頁)
  response.write ("<a href='"& myself &"?page=1'><font color='#000000'>第一頁</font></a> ") 
 end if
 if(pagenmin>1) then'如果頁碼開始值大于1則顯示(更前)
  response.write ("<a href='"& myself &"?page="& page-(pagenc*2+1) &"'><font color='#000000'>更前</font></a> ")
 end if

 if(pagenmax>pagec) then'如果頁碼結束值大于總頁數,則=總頁數
     pagenmax=pagec
 end if

 for i = pagenmin to pagenmax'循環(huán)輸出頁碼
     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'如果頁碼結束值小于總頁數則顯示(更后)
  response.write ("<a href='"& myself &"?page="& page+(pagenc*2+1) &"'><font color='#000000'>更后</font></a> ")
 end if
 if(page<pagec) then'如果頁碼小于總頁數則顯示(最后頁) 
  response.write ("<a href='"& myself &"?page="& pagec &"'><font color='#000000'>最后頁</font></a> ")
 end if
 '設置分頁頁碼結束===============================
 %><script language="javascript">
<!--
function gopage() {
window.location.href="<%=myself%>?page="+ page.value;
}
//-->
</script>
    轉到
   <input name="page" type="text" value="<%=page%>" size="5">頁
   <input type="button" name="submit" value="跳轉" ></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的設置技巧
1、默認語言 打開fckconfig.js文件(相對FCKeditor文件夾,以下同),把自動檢測語言改為不檢測,把默認語言改為簡體中文: 程序代碼 FCKConfig.AutoDetectLanguage = false ; FCKConfig.DefaultLanguage = 'zh-cn' ; 2、字體列表 打開fckconfig.js文件,在字體列表中

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 沅陵县| 金寨县| 蒙阴县| 定日县| 丹凤县| 新兴县| 定陶县| 察雅县| 无棣县| 五寨县| 闵行区| 金门县| 安义县| 准格尔旗| 商都县| 穆棱市| 灵武市| 大方县| 宁德市| 扶绥县| 平安县| 太保市| 新沂市| 瑞金市| 蒙阴县| 遂川县| 云梦县| 定安县| 三台县| 楚雄市| 会东县| 衡山县| 东乡县| 双江| 涞水县| 南木林县| 钟祥市| 广河县| 青河县| 九寨沟县| 老河口市|