简单分页函数一 常用

时间:2021-05-18

复制代码 代码如下:
<%
page=trim(request("page"))
maxperpage=40
first=true
last=true
dimrs
setrs=server.CreateObject("adodb.recordset")
sql="selectid,title,add1,cartype,isred,enterdate,hitsfromnewnewswhereclasstype=0andpass=1orderbyiddesc"
rs.opensql,conn,1,1
rs.pagesize=maxperpage
totalpage=rs.pagecount
iflen(page)=0then
intpage=1
first=false
else
ifcint(page)<=1then
intpage=1
first=false
else
ifcint(page)>=rs.pagecountthen
intpage=rs.pagecount
last=false
else
intpage=cint(page)
endif
endif
endif
ifnotrs.eofthen
rs.absolutepage=intpage
endif
fora=1tomaxperpage
ifrs.eofthenexitfor
%>
<tr<%if(amod2)=0then
response.write"bgcolor=#ffffff"
else
response.write"bgcolor=#f6f6f6"
endif
%>>
<tdheight="20"><divalign="center"><%=a%></div></td>
<td><divalign="center">
<%add=rs("add1")
substringadd,4
%>
</div></td>
<td>
<ahref="displaynews.asp?id=<%=rs("id")%>"target="_blank">
<%
ifrs("isred")=Truethen
%>
<fontcolor="red">
<%title=rs("title")
substringtitle,20
%></font>
<%else
title=rs("title")
substringtitle,20
%>
<%
endif
%>
</a></td>
<td><divalign="center"><%=rs("cartype")%></div></td>
<td><divalign="center">
<%thetime=rs("enterdate")
themon=datepart("m",thetime)
iflen(themon)<2thenthemon="0"&themon
theday=datepart("d",thetime)
iflen(theday)<2thentheday="0"&theday
ther=themon&"-"&theday
response.writether
%>
</div></td>
<td><divalign="center"><%=rs("hits")%></div></td>
</tr>
<%
rs.movenext
ifrs.eofthenexitfor
next
%>
</table>
<tablewidth="100%"border="0"cellspacing="0"cellpadding="0">
<tr>
<tdheight="5"></td>
</tr>
</table>
<tablewidth="100%"border="0"cellpadding="0"cellspacing="0">
<tr>
<tdheight="20"bgcolor="#f6f6f6">
<divalign="center">
<%ifrs.pagecount>0then%>
共有<%=rs.recordcount%>条|当前页<%=intpage%>/
<%

=rs.pagecount%>

<%endif%>
<%ifintpage>1then%>
<ahref="<%request.ServerVariables("SCRIPT_NAME")%>?

page=1">首页</a>
<%else%>
首页
<%endif%>
<%iffirstthen%>
<ahref="<%request.ServerVariables("SCRIPT_NAME")%>?

page=<%=intpage-1%>">上一页</a>
<%else%>
上一页
<%endif%>
<%iflastandintpage<rs.pagecountthen%>
<ahref="<%request.ServerVariables("SCRIPT_NAME")%>?

page=<%=intpage+1%>">下一页</a>
<%else%>
下一页
<%endif%>
<%ifintpage<rs.pagecountthen%>
<ahref="<%request.ServerVariables("SCRIPT_NAME")%>?

page=<%=rs.pagecount%>">尾页</a>
<%else%>
尾页
<%endif%>
转到
<selectonChange="location=this.options

[this.selectedIndex].value">
<%forb=1tors.pagecount
ifb=intpagethen%>
<optionvalue="<%request.ServerVariables("SCRIPT_NAME")%>?page=<%=b%>"selected>

第<%=b%>页</option>
<%else%>
<optionvalue="<%request.ServerVariables("SCRIPT_NAME")%>?page=<%=b%>">第<%=b%>页

</option>
<%endif
next%>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
</tr>
</table>
</body>
<%
rs.close
setrs=nothing
conn.close
setconn=nothing
%>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章