<%
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))&"> </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"首頁 上頁 "
else
response.write"<a href="&filename&"?page=1>首頁</a> "
response.write"<a href="&anclassid&"?page="¤tPage-1&">上頁</a> "
end if
if n-currentPage<1 then
response.write"下頁 尾頁 "
else
response.write"<a href="&filename&"?page="¤tPage+1&">下頁</a> "
response.write"<a href="&filename&"?page="&n&">尾頁</a>"
end if
response.write""¤tPage&"/"&n&"頁 "
response.write""&MaxPP&"項/頁"
end function
%>