asp文章分頁

來源:互聯網
上載者:User

<%
num_row=3 '每行放置的產品數
rows=3 '放置的產品行數
maxpp=num_row*rows '分頁需要MaxPP
set rs=server.createobject("adodb.recordset")
sql="select * from shop_books where nclassid="&nid&" order by adddate desc"
rs.open sql,conn,1,1
if rs.eof then
response.Write"No record!"
else
page=cint(request("page"))
strFilename="auction2.asp?lx=big&anid="
if not isempty(request("page")) then
   currentPage=cint(request("page"))
else
   currentPage=1
end if
totalPut=rs.recordcount
if (currentPage-1)*MaxPP>totalPut then
if(totalPut mod MaxPP)=0 then
currentPage=totalPut \ MaxPP
else
currentPage=totalPut \ MaxPP + 1
end if
end if
if currentPage=1 then(www.111cn.net)
showContent
showpage totalPut,MaxPP,strFilename
else
if (currentPage-1)*MaxPP<totalPut then
       rs.move (currentPage-1)*MaxPP
showContent
       showpage totalPut,MaxPP,strFilename
else
currentPage=1
showContent
       showpage totalPut,MaxPP,strFilename
end if
end if
end if
%>
<%sub showContent%>
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
         <%
j=1 '初始化j,它的值是頁面顯示的產品數量
do while not (rs.eof or err) '當存在記錄時
if (j mod num_row)=1 then response.write "<tr>" end if 'j從1開始遞增,開始顯示1行
         %>
             <td width="<%=(100/num_row)%>%" align=center> <TABLE width=100 height=189 cellSpacing=1 cellPadding=2 border=0>
                      <TBODY>
                        <TR>
                          <TD  align=center><%if rs("ta")="" then
response.write "<div align=center><a href=show.asp?id="&rs("bookid")&" ><img src=images/emptybook.gif width=100 height=100 border=0></a></div>"
else%>
                              <a href=show.asp?id=<%=rs("bookid")%> ><img src="<%=trim(rs("gg"))%>"  width=156 border=0 height=93 style="border:#000000 solid 1px"></a>
                              <%end if%>                          </td>
                        </tr>
                        <TR>
                          <TD height=26 bgColor=#ffffff align=center><%
response.write trim(rs("bookname"))%></td>
                        </tr>
                        <TR>
                          <TD height=5 bgColor=#ffffff align=center></td>
                        </tr>
                      </tbody>
                     
                  </table> </td>
            <%
if (j mod num_row)=0 then response.write "</tr>"   end if   '當j的值是num_row的倍數的時候結束一行
j=j+1
if j>maxpp then exit do
rs.moveNext
loop '迴圈啦
%>
<!-- 開始:以下是為當記錄全部顯示而表格列數不夠時補充不夠的列數 -->
<%
dim k
k=(j-1) mod num_row
if not (k=0) then
response.write "<td colspan="&(num_row-k)&" width="&(cint(100/num_row)*(num_row-k))&">&nbsp;</td>"
response.write "</tr>"
end if
         %><!-- 結束 -->
</table>
         <%end sub%> 
<%
function showpage(totalPut,MaxPP,filename)
dim n
if totalPut mod MaxPP=0 then
n=totalPut \ MaxPP
else
n=totalPut \ MaxPP+1
end if
response.write"<form method=Post action="&filename&">"
response.write""
if currentPage<2 then
response.write"首頁 上頁&nbsp;"
else
response.write"<a href="&filename&"?page=1>首頁</a>&nbsp;"
response.write"<a href="&anclassid&"?page="&currentPage-1&">上頁</a>&nbsp;"
end if
if n-currentPage<1 then
response.write"下頁&nbsp;尾頁&nbsp;"
else
response.write"<a href="&filename&"?page="&currentPage+1&">下頁</a>&nbsp;"
response.write"<a href="&filename&"?page="&n&">尾頁</a>"
end if
response.write""&currentPage&"/"&n&"頁&nbsp;"
response.write""&MaxPP&"項/頁"
end function
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.