【编者按】网学网asp频道为大家收集整理了“简单分页函数一 常用“提供大家参考,希望对大家有所帮助!
复制代码 代码如下:
<%
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 th