[原]多行多列产品展示+分页
来源:ASP学习网 作者:Admin 时间:08-05-07 点击:
未分页版本
<!--#include file="Conn.asp"-->
<table cellpadding="0" cellspacing="5"><tr>
<%
dim rs,i,StrSql
set rs=server.createobject("adodb.recordset")
StrSql="select top 25 * from [Product]"
rs.open StrSql,conn,1,1
if rs.eof or rs.bof then
response.Write "没有记录"
end if
i=1
while not (rs.Eof or rs.Bof)
if i mod 5 =0 then
%>
<td Style="height:80px;width:120px;border:solid 1px #00f;padding:3px;">
第<%=i%>个产品<br />
产品名称:<%=rs("productName")%><br />
产品价格:<%=rs("Price")%><br />
产品描述:<%=rs("DesCription")%><br />
产品点击:<%=rs("hit")%><br />
</td>
</tr><tr>
<%else%>
<td Style="height:80px;width:120px;border:solid 1px #00f;padding:3px;">
第<%=i%>个产品<br />
产品名称:<%=rs("productName")%><br />
产品价格:<%=rs("Price")%><br />
产品描述:<%=rs("DesCription")%><br />
产品点击:<%=rs("hit")%><br />
</td>
<%end if%>
<%
rs.MoveNext
i=i+1
Wend
rs.Close
set rs=nothing
%>
</tr></table>
分页版本
<!--#include file="Conn.asp"-->
<!--#include file="ClsSplitPages.asp"-->
<%dim sp,num,Rs,ProductNum
num=15'每页记录条数
set sp=new SplitPages'建立分页类对像
sp.conn=conn'传弟一个记录集
sp.ListFields="*"'筛选的数据列
sp.TableName="product"'表名
sp.OrderString="order by productID asc"'排序方式
sp.Unit="条记录"'记录单位
sp.sizePages=num
sp.ListNum=10'列出当前页附近的几页
'-----------------------
If Request.querystring("pages")="" Then
ProductNum=0
else
ProductNum = num*Cint(Request.querystring("pages")-1)
end If
'-----------------------
%>
分页版本
<table cellpadding="0" cellspacing="5"><tr>
<%Dim i
set rs=sp.GetRS()'取得记录集
if rs.eof then
response.write "<div>暂时还没有记录</div>"
response.End()
End If
for i=1 to num
%>
<%
if i mod 5 =0 then
%>
<td Style="height:80px;width:120px;border:solid 1px #00f;padding:3px;">
第<%=ProductNum+i%>个产品<br />
产品名称:<font color=red><%=rs("productName")%></font><br />
产品价格:<%=rs("Price")%><br&nb