简单分页函数一 常用
简单分页函数一 常用
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:首页首页上一页上一页下一页下一页尾页尾页转到第页第页

复制代码 代码如下:

<%

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>

</div></td>

</tr>

</table>

</body>

<%

rs.close

setrs=nothing

conn.close

setconn=nothing

%>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类