关于ASP循环表格的问题之解答[比较详细]
(编辑:jimmy 日期: 2024/11/17 浏览:3 次 )
下面是代码,如果看不懂,建议先把表格的一些<tr><td>的表格原理弄清楚了,就可以了
复制代码 代码如下:
<table border="0" cellpadding="0" cellspacing="0">
<%
dim rs,sqltext
set rs = Server.CreateObject("adodb.recordset")
sqltext="select * from [bigclass]"
rs.Open sqltext,conn,1,1
m=1
colzs=5 '一行显示5列
if rs.RecordCount mod colzs=0 then
rowzs=int(rs.RecordCount/colzs)
else
rowzs=int(rs.RecordCount/colzs)+1
end if
for j = 1 to rowzs%>
<tr>
<%for i = 1 to colzs%>
<%if not rs.EOF then%>
<td><input type="checkbox" name="qxflag<%=m%>" value="1"><%=trim(rs("bigname"))%></td>
<%
rs.MoveNext
m = m + 1
else
%>
<td> </td>
<%end if%>
<%next%>
</tr>
<%
next
rs.Close
set rs = nothing
%>
</table>
复制代码 代码如下:
<table border="0" cellpadding="0" cellspacing="0">
<%
dim rs,sqltext
set rs = Server.CreateObject("adodb.recordset")
sqltext="select * from [bigclass]"
rs.Open sqltext,conn,1,1
m=1
colzs=5 '一行显示5列
if rs.RecordCount mod colzs=0 then
rowzs=int(rs.RecordCount/colzs)
else
rowzs=int(rs.RecordCount/colzs)+1
end if
for j = 1 to rowzs%>
<tr>
<%for i = 1 to colzs%>
<%if not rs.EOF then%>
<td><input type="checkbox" name="qxflag<%=m%>" value="1"><%=trim(rs("bigname"))%></td>
<%
rs.MoveNext
m = m + 1
else
%>
<td> </td>
<%end if%>
<%next%>
</tr>
<%
next
rs.Close
set rs = nothing
%>
</table>
下一篇:ASP分页类(支持多风格变换)