ASP表格内容循环出错,WEND缺少语句
我有一个产品展示页,3行*2列排布!如果后台数据库有6条或以上的记录,网页就没有问题!但一旦小于6条记录,马上就会WEND错误,我将代码贴到上边,希望大家帮忙解决!请详细...
我有一个产品展示页,3行*2列排布!如果后台数据库有6条或以上的记录,网页就没有问题!但一旦小于6条记录,马上就会WEND错误,我将代码贴到上边,希望大家帮忙解决!请详细解释一下,谢谢了!
<table width="604" height="180" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="eeeeee">
<% strsql="select top 6 * from pro_list order by id desc"
rs.Open strsql, conn, 1, 1
while not rs.eof
%>
<tr>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif"><div align="center" class="blue"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then
rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE2"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE7"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
</tr>
<%
rs.movenext
wend
rs.close
%>
</table> 展开
<table width="604" height="180" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="eeeeee">
<% strsql="select top 6 * from pro_list order by id desc"
rs.Open strsql, conn, 1, 1
while not rs.eof
%>
<tr>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif"><div align="center" class="blue"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then
rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE2"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE7"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
</tr>
<%
rs.movenext
wend
rs.close
%>
</table> 展开
2个回答
展开全部
错在哪里,请看下面有注释的液让地方
<table width="604" height="180" border="0" align="center" cellpadding="0"汪碰 cellspacing="1" bgcolor="eeeeee">
<% strsql="select top 6 * from pro_list order by id desc"
rs.Open strsql, conn, 1, 1
while not rs.eof
%>
<tr>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif"><div align="center" class="blue"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then
rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE2"><%= rs("pro_name") %></div></td>
</tr>
<困埋谈/table>
</div></td>
<% if not rs.eof then rs.movenext
'end if 把这个end if 去掉,if then 后面直接跟语句的话不要end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE7"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
</tr>
<%
rs.movenext
wend
rs.close
%>
</table>
顺便说一句,你这样写程序有点问题,如果不刚好是3的整数倍的话,出的最后三个数据肯定有重复的.
<table width="604" height="180" border="0" align="center" cellpadding="0"汪碰 cellspacing="1" bgcolor="eeeeee">
<% strsql="select top 6 * from pro_list order by id desc"
rs.Open strsql, conn, 1, 1
while not rs.eof
%>
<tr>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif"><div align="center" class="blue"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
<% if not rs.eof then
rs.movenext
end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE2"><%= rs("pro_name") %></div></td>
</tr>
<困埋谈/table>
</div></td>
<% if not rs.eof then rs.movenext
'end if 把这个end if 去掉,if then 后面直接跟语句的话不要end if
%>
<td width="202" bgcolor="#FFFFFF"><div align="center">
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center"><a href="opus_view.asp?id=<%=rs("id")%>"><img src="<%= rs("pro_img") %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="STYLE7"><%= rs("pro_name") %></div></td>
</tr>
</table>
</div></td>
</tr>
<%
rs.movenext
wend
rs.close
%>
</table>
顺便说一句,你这样写程序有点问题,如果不刚好是3的整数倍的话,出的最后三个数据肯定有重复的.
展开全部
帮你改了一下,已测试通过
<table width="604" height="180" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="eeeeee">
<%
strsql="select top 6 * from [pro_list] order by id desc"
set rs=server.createobject("adodb.recordset")'这行如果你前面有,就删掉
rs.Open strsql, conn, 1, 1
if not (rs.eof and rs.bof) then
for i=1 to 2
%>
<tr>
<%for j=1 to 3%>
<td width="202" bgcolor="#FFFFFF" align="center">
<%call showTab()%>
</td>
<%next%>
</弯棚戚tr>
<%
next
end if
%>
</table>
<%rs.Close%>
<%
sub showTab()
if not rs.eof then
id=rs("id")
pro_img=rs("username")
pro_name=rs("username")
rs.movenext
else
id=""
pro_img=""
pro_name=""
end if
%>
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=id%>"><img src="<%= pro_img %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="埋陵STYLE2"><%= pro_name %>和正</div></td>
</tr>
</table>
<%end sub%>
<table width="604" height="180" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="eeeeee">
<%
strsql="select top 6 * from [pro_list] order by id desc"
set rs=server.createobject("adodb.recordset")'这行如果你前面有,就删掉
rs.Open strsql, conn, 1, 1
if not (rs.eof and rs.bof) then
for i=1 to 2
%>
<tr>
<%for j=1 to 3%>
<td width="202" bgcolor="#FFFFFF" align="center">
<%call showTab()%>
</td>
<%next%>
</弯棚戚tr>
<%
next
end if
%>
</table>
<%rs.Close%>
<%
sub showTab()
if not rs.eof then
id=rs("id")
pro_img=rs("username")
pro_name=rs("username")
rs.movenext
else
id=""
pro_img=""
pro_name=""
end if
%>
<table width="161" height="140" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="118"><div align="center" class="STYLE7"><a href="opus_view.asp?id=<%=id%>"><img src="<%= pro_img %>" width="120" height="140" border="0"></a></div></td>
</tr>
<tr>
<td width="187" height="22" background="image/2.gif" class="blue"><div align="center" class="埋陵STYLE2"><%= pro_name %>和正</div></td>
</tr>
</table>
<%end sub%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询