帮忙改一小段程序

piperzero 2006-07-10 09:20:02
<%recent=split(session("recent"),"/")


for i=0 to ubound(recent)
hwid=trim(recent(i))
Set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product where articleid="&hwid&"",conn,1,3%>
<tr><td height="20" width="180"><a target="_blank" href=views.asp?hw_id=<%=rs2("articleid")%>><%=rs2("title")%></a></td>
<td height="20" width="35" align="center"><a href="basket.asp?hw_id=<%=rs2("articleid")%>">
<img border="0" src="img/buy.gif"></a></td></tr>
<%
next%>
如何将这个改成两列显示我本来定义了j
想用if (j mod 2=0) and j>=2 then
但是程序失败.
...全文
155 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
beenchen 2006-07-11
  • 打赏
  • 举报
回复
<%
recent=split(session("recent"),"/")
foreach hwid in recent
Set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product where articleid=" & hwid,conn,1,3
j = 0
while not rs2.eof
%>
<tr>
<td height="20" width="180"><a target="_blank" href=views.asp?hw_id=<%=rs2("articleid")%>><%=rs2("title")%></a></td>
<td height="20" width="35" align="center"><a href="basket.asp?hw_id=<%=rs2("articleid")%>"><img border="0" src="img/buy.gif"></a></td>
</tr>
<%
j = j + 1
if j mod 2 = 0 and j <> 0 then
exit for
end if
rs2.movenext
wend
next
%>

其实不是很明白你想表达的意思,你这个程序本身就只显示的两列。呵呵!
所以这里给出的是显示两行的代码,当然还是两列为一行。
piperzero 2006-07-11
  • 打赏
  • 举报
回复
多谢大家的帮忙,突然发现自己错在哪里了
正确如下
<%
recent=split(session("recent"),"/")
j = 0'放在这里
for i=0 to ubound(recent)
hwid=trim(recent(i))
Set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product where articleid=" & hwid,conn,1,3

while not rs2.eof
j = j + 1
%>

<td height="20" width="180"><a target="_blank" href=views.asp?hw_id=<%=rs2("articleid")%>><%=rs2("title")%></a></td>
<td height="20" width="35" align="center"><a href="basket.asp?hw_id=<%=rs2("articleid")%>"><img border="0" src="img/buy.gif"></a></td>

<%

if j mod 2 = 0 and j >=2 Then
response.write("</tr>")

end if
rs2.movenext
wend
next
%>
littlelam 2006-07-10
  • 打赏
  • 举报
回复
<%
recent=split(session("recent"),"/")
for i=0 to ubound(recent)
hwid=trim(recent(i))
Set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product where articleid="&hwid&"",conn,1,3
Response.Write("<tr>")
j=0
do while not rs2.eof
j=j+1
%>
<td height="20" width="180"><a target="_blank" href=views.asp?hw_id=<%=rs2("articleid")%>><%=rs2("title")%></a></td><td height="20" width="35" align="center"><a href="basket.asp?hw_id=<%=rs2("articleid")%>"><img border="0" src="img/buy.gif"></a></td>
<%
if j mod 2 =0 and j<>rs2.recordcount then response.write("</tr><tr>")
rs2.movenext
loop
Response.Write("</tr>")
next
%>
littlelam 2006-07-10
  • 打赏
  • 举报
回复
<tr>
<%
recent=split(session("recent"),"/")
for i=0 to ubound(recent)
hwid=trim(recent(i))
Set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from product where articleid="&hwid&"",conn,1,3
j=0
do while not rs2.eof
j=j+1
%>
<td height="20" width="180"><a target="_blank" href=views.asp?hw_id=<%=rs2("articleid")%>><%=rs2("title")%></a></td><td height="20" width="35" align="center"><a href="basket.asp?hw_id=<%=rs2("articleid")%>"><img border="0" src="img/buy.gif"></a></td>
<%
if j mod 2 =0 and j<>rs2.recordcount then response.write("</tr><tr>")
rs2.movenext
loop
next
%>
</tr>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧