asp分页

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

asp分页

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">

<tr>

<td colspan="5" valign="top"><IMG SRC="../images/user-1_08.gif" WIDTH=1 HEIGHT=1></td>

</tr>

<tr valign="top" bgcolor="#FCD2EE">

<td height="30" colspan="5" align="left"><img src="../images/icon1.gif"><a href="write.asp">+日记</a>&nbsp;&nbsp;<a href="index.asp">+心情日记</a></td>

</tr>

<tr bgcolor="#ffcccc">

<td width="23%" height="30">日期</td>

<td width="47%" height="30">标题</td>

<td width="8%"> 保密</td>

<td width="8%">浏览数</td>

<td width="14%">操作</td>

</tr>

<%

dim i,intPage,page,pre,last,filepath

set rs = server.CreateObject("adodb.recordset")

sql="select id,savetime,title,hits,issecret from f_diaries where uid='"&session("uid")&"' order by id desc"

rs.PageSize = 20 '这里设定每页显示的记录数

rs.CursorLocation = 3

rs.Open sql,conn,0,2,1 '这里执行你查询SQL并获得结果记录集

pre = true

last = true

page = trim(Request.QueryString("page"))

if len(page) = 0 then

intpage = 1

pre = false

else

if cint(page) =< 1 then

intpage = 1

pre = 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 i=1 to rs.PageSize

if rs.EOF or rs.BOF then exit for

%>

<tr>

<td height="25"><%=trim(rs("savetime"))%></td>

<td height="25" align="left"><a href="show.asp?id=<%=trim(rs("id"))%>"><%if len(trim(rs("title")))>20 then

response.Write left(trim(rs("title")),20)

response.Write "..."

else

response.Write trim(rs("title"))

end if

%></a></td>

<td><%if rs("issecret")=0 then%>公开<%else%>保密<%end if%></td>

<td height="25"><%=trim(rs("hits"))%></td>

<td height="25"><a href="del.asp?id=<%=trim(rs("id"))%>">删除</a>&nbsp;<a href="change.asp?id=<%=trim(rs("id"))%>">修改</a></td>

</tr>

<%

rs.movenext

next

%>

<tr>

<td colspan="6">

<table width="99%" border="1" cellpadding="2" bgcolor="#ffcccc" cellspacing="2" borderColorLight="#808080" borderColorDark="#ffffff">

<tr>

<%if rs.pagecount > 0 then%>

<td width="23%" align="left">当前页<font color="#ff0000"><%=intpage%></font>/<%=rs.PageCount%>&nbsp;&nbsp; <%=rs.PageSize%>篇/页 </td>

<%else%>

<td width="15%" align="left">当前页0/0</td><%end if%>

<td width="62%" align="right"> <a href="index.asp?page=1">首页</a>|

<%if pre then%>

<a href="index.asp?page=<%=intpage -1%>">上页</a>| <%end if%>

<%if last then%>

<a href="index.asp?page=<%=intpage +1%>">下页</a> |<%end if%>

<a href="index.asp?page=<%=rs.PageCount%>">尾页</a>|转到第

<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">

<%

for i = 1 to rs.PageCount

if i = intpage then%>

<option value="index.asp?page=<%=i%>" selected><%=i%></option>

<%else%>

<option value="index.asp?page=<%=i%>"><%=i%></option>

<%

end if

next

%>

</select>页</font>

</td>

</tr>

</table>

</td>

</tr>

<%

rs.close

set rs=nothing

%>

</table>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航