【www.gdgbn.com--php常用代码】

<%
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        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%>
             
         <%
j=1 "初始化j,它的值是页面显示的产品数量
do while not (rs.eof or err) "当存在记录时
if (j mod num_row)=1 then response.write "" end if "j从1开始递增,开始显示1行
         %>
             %" align=center>
                     
                       
                          <%if rs("ta")="" then
response.write ""
else%>
                              >"  width=156 border=0 height=93 style="border:#000000 solid 1px">
                              <%end if%>                         
                       
                       
                          <%
response.write trim(rs("bookname"))%>
                       
                       
                         
                       
                     
                     
                 
            <%
if (j mod num_row)=0 then response.write ""   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 " "
response.write ""
end if
         %>

         <%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"

"
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""¤tPage&"/"&n&"页 "
response.write""&MaxPP&"项/页"
end function
%>

本文来源:http://www.gdgbn.com/jiaocheng/14166/