ASP 使用 MOD 控制表格列数

在 ASP 开发中常常需要利用程序控制表格的列数,以达到一定的效果,今天贴出一个不常用的方法,是用MOD控制的。

ASP代码1

<table border="0" cellpadding="0" cellspacing="4"  style="border-collapse: collapse" width="100%" id="autonumber12" height="1">
<%i=0
do while not rss.eof
if i>30 then exit do
if i mod 4=0 then response.write "<tr>"%>
<td width="25%" height="1" align="center"><%=rss("p_no")%</td>
<%i=i+1
if i mod 4=0 then response.write "</tr>"
rss.movenext
loop
if i mod 4<>0 then response.write "</tr>"%>
</table>


ASP代码2

<table>
<tr>
<%
i=1
do while not rs.eof
%>
<td><%=rs(0)%></td>
<td><%=rs(1)%></td>
<td><%=rs(2)%></td>
<td><%=rs(3)%></td>
<%if i mode 4=0 then
response.write "</tr><tr>"
i=0
end if
i=i+1
rs.movenext
loop
%>
</tr>
</table>

2 thoughts to “ASP 使用 MOD 控制表格列数”

  1. 您好,请问您上面代码片段的表格样式是单独的插件还是您自己设计的css?我感觉非常漂亮,我也正想要一个类似的专门发表代码的样式,可以告诉我下吗?

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注