日期:2014-05-17  浏览次数:20724 次

救高手指点一下,代码需求如下!
<div class="weekly_content_list">
  <%'开始分页
  Const MaxPerPage=2
  dim totalPut  
  dim CurrentPage
  dim TotalPages
  dim j
   
  if Not isempty(request("page")) then
  currentPage=Cint(request("page"))
  else
  currentPage=1
  end if
Set Rs = Db.CreateRS()
sql="select * from weekly"
sql="select * from weeklySort where ID>0"
namekey=FLib.SafeSql(Request("namekey"))
if namekey<>"" then
sql=sql&" and SortName like '%"&namekey&"%'"  
end if
if SortID<>"" then
sql=sql&" and SortID="&SortID&""
end if
sql=sql&" order by PX desc"
Rs.Open Sql, Db.Conn, 1, 1
   
  if err.number<>0 then
  response.write "数据库中无数据"
  end if
   
  if rs.eof And rs.bof then
  Response.Write "<p align='center' class='contents'> 没有此类信息!<a href='#' onclick='history.go(-1);'>返回上一步</a></p>"
  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,"weekly.asp"
  else
  if (currentPage-1)*MaxPerPage<totalPut then
  rs.move (currentPage-1)*MaxPerPage
  dim bookmark
  bookmark=rs.bookmark
  showContent
  showpage totalput,MaxPerPage,"weekly.asp"
  else
  currentPage=1
  showContent
  showpage totalput,MaxPerPage,"weekly.asp"
  end if
  end if
  end if

  sub showContent
  dim i
  i=0
  %>
  <div>
  <%
  cols=3
do while not rs.eof
if abc mod cols=0 then response.Write("<tr>")
abc=abc+1
%>
   
  <div class="weekly_content_list_table">
  <div class="weekly_content_list_time">
  <img src="../<%=rs("SmallPic")%>" />
  </div>
  <div class="weekly_content_list_name" style="background-color:#999; text-align:center; font-size:17px;"><%=rs("SortName")%></div>
  <div class="weekly_content_list_name">
  <li><a href="#">小标题2</a></li>
  <li><a href="#">小标题2</a></li>
  <li><a href="#">小标题2</a></li>
  <li><a href="#">小标题2</a></li>
  </div>
  </div>

<%
  i=i+1
  if i>=MaxPerPage then Exit Do
  rs.movenext
  loop
  rs.close
  set rs=nothing%>
  </div>
  </div>

------解决方案--------------------
完整的分页例子
<table border="0" width="775" id="table39" height="466" cellspacing="0" cellpadding="0" align="center">