ASP表格换行,每行4个,然后换行 50
functionTopProducts()dimrs,sql,i,ProductName,SmallPicPathsetrs=server.createobject("a...
function TopProducts()
dim rs,sql,i,ProductName,SmallPicPath
set rs = server.createobject("adodb.recordset")
sql="select ID,ProductName"&LangData&",SortID,SmallPic,GroupID,Exclusive from NwebCn_Products where ViewFlag"&LangData&" and NewFlag order by id desc"
rs.open sql,conn,1,1
response.write"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
response.write "<tr><td height='20'></td></tr>"
if rs.bof and rs.eof then
response.write "<tr><td align='center'>暂无相关信息</td></tr>"
else
response.write"<tr>"
for i=1 to 4
if rs.eof then exit for
response.write"<td width='25%'>"
if StrLen(rs("ProductName"&LangData))<=20 then
ProductName=rs("ProductName"&LangData)
else
ProductName=StrLeft(rs("ProductName"&LangData),18)
end if
SmallPicPath=HtmlSmallPic(rs("GroupID"),rs("SmallPic"),rs("Exclusive"))
response.write "<table align='center' border='0' cellpadding='0' cellspacing='0' >" &_
"<tr><td align='center' width='142' height='142' style='text-decoration: underline; " &_
"border: 1px solid #CCCCCC;'><a href='ProductView.asp?ID="&rs("id")&"&SortID="&rs("SortID")&"'>" &_
"<img src='"&SmallPicPath&"' border='0' width='140' height='140' onload='javascript:DrawImage(this,140,140);'></a>" &_
"</td></tr><tr><td height='32'><img src='Images/Arrow_01.gif' width='14' height='11'" &_
" align='absmiddle'> <a href='ProductView.asp?ID="&rs("id")&"&SortID="&rs("SortID")&"'>"&ProductName&"</a></td></tr></table>"
response.write"</td>"
rs.movenext
next
response.write"</tr>"
end if
response.write "</table>"
rs.close
set rs=nothing
end function
%> 展开
dim rs,sql,i,ProductName,SmallPicPath
set rs = server.createobject("adodb.recordset")
sql="select ID,ProductName"&LangData&",SortID,SmallPic,GroupID,Exclusive from NwebCn_Products where ViewFlag"&LangData&" and NewFlag order by id desc"
rs.open sql,conn,1,1
response.write"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
response.write "<tr><td height='20'></td></tr>"
if rs.bof and rs.eof then
response.write "<tr><td align='center'>暂无相关信息</td></tr>"
else
response.write"<tr>"
for i=1 to 4
if rs.eof then exit for
response.write"<td width='25%'>"
if StrLen(rs("ProductName"&LangData))<=20 then
ProductName=rs("ProductName"&LangData)
else
ProductName=StrLeft(rs("ProductName"&LangData),18)
end if
SmallPicPath=HtmlSmallPic(rs("GroupID"),rs("SmallPic"),rs("Exclusive"))
response.write "<table align='center' border='0' cellpadding='0' cellspacing='0' >" &_
"<tr><td align='center' width='142' height='142' style='text-decoration: underline; " &_
"border: 1px solid #CCCCCC;'><a href='ProductView.asp?ID="&rs("id")&"&SortID="&rs("SortID")&"'>" &_
"<img src='"&SmallPicPath&"' border='0' width='140' height='140' onload='javascript:DrawImage(this,140,140);'></a>" &_
"</td></tr><tr><td height='32'><img src='Images/Arrow_01.gif' width='14' height='11'" &_
" align='absmiddle'> <a href='ProductView.asp?ID="&rs("id")&"&SortID="&rs("SortID")&"'>"&ProductName&"</a></td></tr></table>"
response.write"</td>"
rs.movenext
next
response.write"</tr>"
end if
response.write "</table>"
rs.close
set rs=nothing
end function
%> 展开
1个回答
展开全部
说一下 循环结构
<table>
<tr>
<% dim i
i=0
do while NOT Recordset1.EOF
i=i+1
%>
<td>
<!--这里放希望调用的单元-->
<td>
<%
if i mod 4 =0 then
response.write "</tr><tr>"
end if
Recordset1.movenext
Loop
%>
</tr>
</table>
原理就是循环td 根据条件换行(</tr><tr>)
如果你是分行显示就循环tr
<table>
<tr>
<% dim i
i=0
do while NOT Recordset1.EOF
i=i+1
%>
<td>
<!--这里放希望调用的单元-->
<td>
<%
if i mod 4 =0 then
response.write "</tr><tr>"
end if
Recordset1.movenext
Loop
%>
</tr>
</table>
原理就是循环td 根据条件换行(</tr><tr>)
如果你是分行显示就循环tr
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询