表演教学视频:asp 表格的循环,急求救!!
来源:百度文库 编辑:查人人中国名人网 时间:2024/05/12 05:38:00
我想实现的是循环一个表格,一行有三个格,内容是从数据库中调用(图片+标题),当第一行的内容结束后自动循环至第二行,现在我将每页的最多页数设为30,也就是说,结果是一个十行三列的表格.但是我循环的结果总是一行一列.并且图象重复!请高人指教!!
代码如下:
<table >
<%
Sql = "略"
rs.open sql,conn,1,1
if Rs.eof and Rs.bof then
response.Write("该栏目下还没有添加文章。")
else
totalPut=rs.recordcount
(此处为页码翻页设)
rs.close
set rs = nothing
end if
sub showContent
dim i,j
i=0
do while not rs.eof
Unid = rs(0)
title = rs(1)
content = rs(2)
Nclassid = rs(3)
hits = rs(4)
intime = rs(5)
pic = rs(6)
DefaultPic = rs(7)
synopsis = rs(8)
%>
<tr>
<%
for j=0 to 0
If Rs.Eof Then
Exit For
End If
%>
<td>
<table border="0" width="100" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<%
response.write("<td >")
Response.Write("<a href=list.asp?unid="& rs(0) &" target='"& AddOpenWin &"'>" & DefaultPic & "</a>")
response.write("</td>")
%>
</tr>
<tr align="center">
<%
response.write("<td >")
Response.Write("<a href=list.asp?unid="& rs(0) &" target='"& AddOpenWin &"'>" & title & "</a>")
response.write("</td>")
%>
</tr>
</table>
</td>
<%
Rs.Movenext
Next
%>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
function showpage
(此处略)
end function
%>
</td>
</tr>
</table>
代码如下:
<table >
<%
Sql = "略"
rs.open sql,conn,1,1
if Rs.eof and Rs.bof then
response.Write("该栏目下还没有添加文章。")
else
totalPut=rs.recordcount
(此处为页码翻页设)
rs.close
set rs = nothing
end if
sub showContent
dim i,j
i=0
do while not rs.eof
Unid = rs(0)
title = rs(1)
content = rs(2)
Nclassid = rs(3)
hits = rs(4)
intime = rs(5)
pic = rs(6)
DefaultPic = rs(7)
synopsis = rs(8)
%>
<tr>
<%
for j=0 to 0
If Rs.Eof Then
Exit For
End If
%>
<td>
<table border="0" width="100" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<%
response.write("<td >")
Response.Write("<a href=list.asp?unid="& rs(0) &" target='"& AddOpenWin &"'>" & DefaultPic & "</a>")
response.write("</td>")
%>
</tr>
<tr align="center">
<%
response.write("<td >")
Response.Write("<a href=list.asp?unid="& rs(0) &" target='"& AddOpenWin &"'>" & title & "</a>")
response.write("</td>")
%>
</tr>
</table>
</td>
<%
Rs.Movenext
Next
%>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
function showpage
(此处略)
end function
%>
</td>
</tr>
</table>
<%
....
....
i=0
do while i< maxperpage and not rs.eof
%>
<%
if i mod 3=0 then response.write "<tr>"
'当i=0,3,6,9时输出<tr>
%>
<td align="left" height=80><%=rs("XXXXX")%></td>
<%if i+1 mod 3=0 then response.write "</tr>"%>
'当i=2,5,8时,输出</tr>
<%
rs.movenext
i=i+1
loop
。。。
%>
可以参考一下以下程序
<table border=1>
<%
for i =0 to 25
if i mod 3 =0 then response.write "<tr>"
%>
<td><%=i%></td>
<%
if i+1 mod 3=0 then response.write "</tr>"
next
%>
</table>
for j=0 to 0
错误