<% '打开数据记录 set rs=server.CreateObject("ADODB.RECORDSET") sql="select * from xxxx order by yyyy desc" 'xxxx,yyyy根据自己的情况修改 rs.open sql,conn,1,1 if rs.eof and rs.bof then response.Write("当前还没有内容...") else dim currentpage maxperpage=20 '修改每页显示记录数 rs.pagesize=maxperpage currentpage=request.querystring("pageid") if currentpage="" then currentpage=1 elseif currentpage<1 then currentpage=1 else currentpage=clng(currentpage) if currentpage > rs.pagecount then currentpage=rs.pagecount end if end if if not isnumeric(currentpage) then currentpage=1 end if dim totalput,n totalput=rs.recordcount if totalput mod maxperpage=0 then n=totalput\maxperpage else n=totalput\maxperpage+1 end if if n=0 then n=1 end if rs.move(currentpage-1)*maxperpage i=0 w=1 do while i< maxperpage and not rs.eof %>
<!--这里显示内容-->
<% '循环记录 i=i+1 w=w+1 rs.movenext loop end if rs.close set rs=nothing %>
<!--调用分页代码--> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr><td width="85%" align="center"> 共有<font color="#FF0000"><%=totalput%></font>篇 每页<%=maxperpage%>篇 当前页数:<%=currentpage%>/<% =n%> <%k=currentpage if k<>1 then%> <a href="?pageid=1"> <font face=webdings size=2>9</font>首 页</a> <a href="?pageid=<%=k-1%>"> <font face=webdings size=2>7</font>前 页</a> <%else%> <font face=webdings size=2>9</font>首 页 <font face=webdings size=2>7</font>前 页 <%end if%> <%if k<>n then%> <a href="?pageid=<%=k+1%>"> 后 页<font face=webdings size=2>8</font></a> <a href="?pageid=<%=n%>"> 末 页<font face=webdings size=2>:</font></a> <%else%> 后 页<font face=webdings size=2>8</font> 末 页<font face=webdings size=2>:</font> <%end if%> </td> <td width="15%" align="center"><select name="pageid" onchange="javascript:location=this.options[this.selectedIndex].value;"> <% for i = 1 to n if i = currentpage then%> <option value="?pageid=<%=i%>" selected>第<%=i%>页</option> <%else%> <option value="?pageid=<%=i%>">第<%=i%>页</option> <% end if next %> </select> </td> </tr> </table>
|