<%'开始分页 Const MaxPerPage=20 dim totalPut dim CurrentPage dim TotalPages dim j dim sql if Not isempty(request("page")) then currentPage=Cint(request("page")) else currentPage=1 end if set rs=server.CreateObject("adodb.recordset") rs.open "select * from news order by id desc",conn,1,1 if err.number<>0 then response.write "数据库中无数据" end if if rs.eof And rs.bof then Response.Write "

数据库中无数据!

" else totalPut=rs.recordcount if currentpage<1 then currentpage=1 end if if (currentpage-1)*MaxPerPage>totalput then if (totalPut mod MaxPerPage)=0 then currentpage= totalPut \ MaxPerPage else currentpage= totalPut \ MaxPerPage + 1 end if end if if currentPage=1 then showContent showpage totalput,MaxPerPage,"list.asp" else if (currentPage-1)*MaxPerPage <% do while not rs.eof%> <%i=i+1 if i>=MaxPerPage then Exit Do rs.movenext loop rs.close set rs=nothing%>
编号

主题

日期
<%=rs("id")%>
<%=rs("date")%>
 
<% End Sub Function showpage(totalnumber,maxperpage,filename) Dim n If totalnumber Mod maxperpage=0 Then n= totalnumber \ maxperpage Else n= totalnumber \ maxperpage+1 End If Response.Write "
" Response.Write "

" If CurrentPage<2 Then Response.Write "首页  上一页 " Else Response.Write "首页 " Response.Write "上一页 " End If If n-currentpage<1 Then Response.Write "下一页  尾页" Else Response.Write "" Response.Write "下一页 尾页" End If Response.Write "   ["&CurrentPage&"]/["&n&"]页 " Response.Write " 共"&totalnumber&"条" Response.Write "  转到:" Response.Write " " End Function %>

关闭窗口