asp如何控制行数和列数的显示

来源:百度知道 编辑:UC知道 时间:2024/04/29 10:37:14
asp显示网页数据中,如何动态显示成为我下面描述的格式
从数据库检索出11条记录
1.××××× 2.××××× 3.×××××
4.××××× 5.××××× 6.×××××
7.××××× 8.××××× 9.×××××
10.××××× 11.×××××
从数据库检索出2条记录
1.××××× 2.×××××
从数据库检索出3条记录
1.××××× 2.××××× 3.×××××
从数据库检索出4条记录
1.××××× 2.××××× 3.×××××
4.×××××
不会出现变形
<table>
<tr>
这里循环显示三条记录
<td>
</td>
如果记录小于三条
就结束显示</tr>
如果记录大于三条小于6条
就显示
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>

</table>

for ltp=1 to objrs.recordcount
response.write 数据库第ltp个记录的数据

if ltp mod 3 = 0 then
response.write "<br>"
else
response.write " "
end if

next
response.write "<br>"

如果用表格,格式更好控制一些:

<table>
<%
lrec =objrs.recordcount
for ltp=1 to lrec
if ltp mod 3 = 1 then response.write "<tr>"
response.write "<td width=200>"
response.write 数据库第ltp个记录的数据

response.write "</td">
if ltp mod 3 = 0 then response.write "</tr>"
next
ltp=3-(lrec mod 3)
if ltp<>3 then response.write "<td colspan=""" & CStr(ltp) & """></td></tr>"
%>
</table>
====================================
因为数据记录数不一定为3的整数倍,因此表格还需要做跨列单元格计算,详见上边的表格控制部分.

预订好表格,用游标移动来判断

用div