方法一:
<table width="100%" align="center">
<%for i=1 to rs.recordcount
if (i mod 3=1) then
response.write"<tr>"
end if
response.write"<td>"&rs("XXX")&"</td>"
if (i mod 3=0) then
response.write"</tr>"
end if
rs.movenext
next%>
</table>
代码一目了然,重点是第七行----if (i mod 3=0) then
这里是排成3列的,如果你想排成更多或更少,可自行修改。
方法二:
<%set rs=server.CreateObject("adodb.recordset")
SQL = "Select * From Shop_books Order By Adddate Desc"
rs.open SQL,conn,1,1
%>
<tr>
<td>
<table width="193" border="0" cellpadding="5" cellspacing="0">
<tr>
<% dim j
j=0
do while not rs.eof %>
<td width="193">
<table width="168" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="163"><a href=list03.asp?id=<%=rs("bookid")%>><img src="<%=trim(rs("bookpic"))%>" width="140" height="100" border="0" class="blue"></a></td>
</tr>
<tr>
<td valign="top"><a href="list.asp03?id=<%=Rs("bookid")%>" class="word-red13-bold"><%=Rs("bookname")%></a><br>
<%=Rs("bookcontent")%><br> <br> <span class="word-grey12"> 市场价:<%=Rs("shichangjia")%>元<br>
会员价:<%=Rs("huiyuanjia")%>元<br>
VIP价:<%=Rs("vipjia")%>元</span></td>
</tr>
<tr>
<td height="30">
<div align="right"></div>
<div align="right">
<table width="90%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><div align="right"><a href="gouwu.asp?id=<%=rs("bookid")%>&action=add"><img src="images/2_01.gif" width="46" height="20" border="0"></a>
<a href="shoucang.asp?id=<%=rs("bookid")%>&action=add"><img src="images/2_03.gif" width="46" height="20" border="0"></a>
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
<% rs.movenext
j=j+1
if rs.eof then
exit do
end if
if j>=3 then exit do
loop
'rs.close
'set rs= nothing %>