簡(jiǎn)單分頁(yè)函數(shù)一 常用
更新時(shí)間:2006年08月07日 00:00:00 作者:
復(fù)制代碼 代碼如下:
<%
page=trim(request("page"))
maxperpage=40
first=true
last=true
dim rs
set rs=server.CreateObject("adodb.recordset")
sql="select id,title,add1,cartype,isred,enterdate,hits from newnews where classtype=0 and pass=1 order by id desc"
rs.open sql,conn,1,1
rs.pagesize=maxperpage
totalpage=rs.pagecount
if len(page)=0 then
intpage=1
first=false
else
if cint(page)<=1 then
intpage=1
first=false
else
if cint(page)>=rs.pagecount then
intpage=rs.pagecount
last=false
else
intpage=cint(page)
end if
end if
end if
if not rs.eof then
rs.absolutepage=intpage
end if
for a=1 to maxperpage
if rs.eof then exit for
%>
<tr <%if (a mod 2)=0 then
response.write "bgcolor=#ffffff"
else
response.write "bgcolor=#f6f6f6"
end if
%>>
<td height="20"><div align="center"><%=a%></div></td>
<td><div align="center">
<%add=rs("add1")
substring add,4
%>
</div></td>
<td>
<a href="displaynews.asp?id=<%=rs("id")%>" target="_blank">
<%
if rs("isred")=True then
%>
<font color="red">
<%title=rs("title")
substring title,20
%></font>
<%else
title=rs("title")
substring title,20
%>
<%
end if
%>
</a></td>
<td><div align="center"><%=rs("cartype")%></div></td>
<td><div align="center">
<%thetime=rs("enterdate")
themon=datepart("m",thetime)
if len(themon)<2 then themon="0"&themon
theday=datepart("d",thetime)
if len(theday)<2 then theday="0"&theday
ther=themon&"-"&theday
response.write ther
%>
</div></td>
<td><div align="center"><%=rs("hits")%></div></td>
</tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" bgcolor="#f6f6f6">
<div align="center">
<%if rs.pagecount>0 then %>
共有<%=rs.recordcount%>條|當(dāng)前頁(yè)<%=intpage%>/
<%
=rs.pagecount%>
<% end if %>
<%if intpage>1 then%>
<a href="<%request.ServerVariables("SCRIPT_NAME")%>?
page=1">首頁(yè)</a>
<%else%>
首頁(yè)
<%end if%>
<%if first then%>
<a href="<%request.ServerVariables("SCRIPT_NAME")%>?
page=<%=intpage-1%>">上一頁(yè)</a>
<%else%>
上一頁(yè)
<%end if%>
<%if last and intpage<rs.pagecount then%>
<a href="<%request.ServerVariables("SCRIPT_NAME")%>?
page=<%=intpage+1%>">下一頁(yè)</a>
<%else%>
下一頁(yè)
<%end if%>
<%if intpage<rs.pagecount then%>
<a href="<%request.ServerVariables("SCRIPT_NAME")%>?
page=<%=rs.pagecount%>">尾頁(yè)</a>
<%else%>
尾頁(yè)
<%end if%>
轉(zhuǎn)到
<select onChange="location=this.options
[this.selectedIndex].value">
<%for b=1 to rs.pagecount
if b=intpage then%>
<option value="<%request.ServerVariables("SCRIPT_NAME")%>?page=<%=b%>" selected>
第<%=b%>頁(yè)</option>
<% else %>
<option value="<%request.ServerVariables("SCRIPT_NAME")%>?page=<%=b%>">第<%=b%>頁(yè)
</option>
<%end if
next%>
</select>
</div></td>
</tr>
</table>
</body>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
相關(guān)文章
用ASP實(shí)現(xiàn)分級(jí)權(quán)限控制
用ASP實(shí)現(xiàn)分級(jí)權(quán)限控制...2007-09-09asp下刪除Access數(shù)詞庫(kù)中的空記錄的sql語(yǔ)句
asp下刪除Access數(shù)詞庫(kù)中的空記錄的sql語(yǔ)句...2007-04-04asp OpenTextFile文本讀取與寫(xiě)入實(shí)例代碼
打開(kāi)指定的文件并返回一個(gè) TextStream 對(duì)象,可以讀取、寫(xiě)入此對(duì)象或?qū)⑵渥芳拥轿募?2008-08-08ASP調(diào)用WebService轉(zhuǎn)化成JSON數(shù)據(jù),附j(luò)son.min.asp
接觸WebService也很久了,但是使用asp調(diào)用教程的卻不多,還有轉(zhuǎn)成json也不多見(jiàn),本文全部分享給大家,需要的拿去吧。2016-03-03通過(guò)MSXML2自動(dòng)獲取QQ個(gè)人頭像及在線情況(給初學(xué)者)
通過(guò)MSXML2自動(dòng)獲取QQ個(gè)人頭像及在線情況(給初學(xué)者)...2007-03-03asp access數(shù)據(jù)庫(kù)并生成XML文件范例
簡(jiǎn)單asp加載access數(shù)據(jù)庫(kù),并生成XML,然后再將XML數(shù)據(jù)加載進(jìn)LIST組件范例學(xué)習(xí)。2009-04-04用ASP生成UTF-8網(wǎng)頁(yè)文件的兩種方法
用ASP生成UTF-8網(wǎng)頁(yè)文件的兩種方法...2007-07-07