<% if Request.QueryString("page").Count > 0 then currentPage = Int(Request.QueryString("page")) else currentPage = 1 end if previousPage = currentPage - 1 nextPage = currentPage + 1 Set connection = Server.CreateObject("ADODB.Connection") connection.Open connectionStringNews Set command = Server.CreateObject("ADODB.Command") command.ActiveConnection = connection command.CommandText = "SELECT TOP 15 * FROM specials WHERE id NOT IN (SELECT TOP " & previousPage*15 & " id FROM specials ORDER BY createTime DESC) ORDER BY createTime DESC" Set resultSet = command.Execute %>
<% i = -1 While resultSet.EOF = False i = i + 1 if Int(i/3)*3 = i and i <> 0 then %> <% end if %> <% resultSet.MoveNext Wend select case Int(i/3) case 1 %> <% case 2 %> <% end select %>
<% resultSet.Close Set resultSet = Nothing Set command = Server.CreateObject("ADODB.Command") command.ActiveConnection = connection command.CommandText = "SELECT COUNT(*) amount FROM specials" Set resultSet = command.Execute amount = resultSet("amount") pages = Int(amount/15) if amount <> pages*15 then pages = pages + 1 end if resultSet.Close Set resultSet = Nothing connection.Close Set connection = Nothing %> <% if pages > 0 then %> <% end if %>
当前是第<%=currentPage%>页,共<%=pages%>页   <% if currentPage = 1 then %> 首页 <% else %> 首页 <% end if %>   <% if previousPage = 0 then %> 上一页 <% else %> 上一页 <% end if %>   <% if nextPage > pages then %> 下一页 <% else %> 下一页 <% end if %>   <% if currentPage = pages then %> 末页 <% else %> 末页 <% end if %>