手机
当前位置:查字典教程网 >编程开发 >ASP教程 >简单分页函数一 常用
简单分页函数一 常用
摘要:复制代码代码如下:首页首页上一页上一页下一页下一页尾页尾页转到第页第页

复制代码 代码如下:

<%

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 四舍五入FormatNumber函数用法

如何限制同一用户名同时登陆

读取目录下的文件得到一个数组

分页代码

asp分页的一个类

asp 日期格式化函数

flash和asp分页的一点心得与flash脚本

精品推荐
分类导航