asp if循环语句
<%'创建对象实例i=0strSql="selecttop6*fromarticlewheretype='高层访谈'orderbyiddesc"setrs=conn.ex...
<%
'创建对象实例
i=0
strSql = "select top 6 * from article where type='高层访谈'order by id desc"
set rs = conn.execute(strSql)
while (not rs.eof) and (not rs.bof)
if i=0 then
mb_code+CSTR(i)="<div class='specialconntent'><div class='specialpic'><img src='" & rs("PhotoUrl") & "' width='70px' height='80px' alt='" & rs("gcname") & " " & rs("gcJob") & "'/></div><div class='spicconntent'><a href='news.asp?id=" & rs("ID") & "' target='_blank' class='red' title='" & rs("gcJob") & "'>" & rs("gcname") & "</a><br /> <a href='news.asp?id=" & rs("ID") & "' target='_blank'>" & left(trim(rs("jianjie")),42) & "...</a></div></div>"
else
mb_code+CSTR(i)=)"<div class='speciallist'><img src='images/icon07.gif' width='10' height='10' /><a href='news.asp?id=" & rs("ID") & "' target='_blank' class='red' title='" & rs("gcJob") & "'>"& rs("gcname") &"</a>:<a href='news.asp?id=" & rs("ID") & "' target='_blank' title='" & rs("title") & "'>" & left(trim(rs("title")),17) & "</a></div>"
end if
i=i+1
rs.MoveNext()
wend
%><!--left_special2-->
<%
set fso=server.CreateObject("scripting.filesystemobject")
set txt=fso.CreateTextFile(server.MapPath("left_special2.html"))''2代表覆盖原文件
txt.write mb_code+CSTR(i)
txt.close
%>
mb_code+CSTR(i)=
现在语句是错误的,我要实现这种方式可以实现么,怎么实现,循环的输出
<%
set fso=server.CreateObject("scripting.filesystemobject")
set txt=fso.CreateTextFile(server.MapPath("left_special2.html"))''2代表覆盖原文件
'创建对象实例
i=0
strSql = "select top 6 * from article where type='高层访谈'order by id desc"
set rs = conn.execute(strSql)
while (not rs.eof) and (not rs.bof)
if i=0 then
mb_code=mb_code&"<div class='specialconntent'><div class='specialpic'><img src='" & rs("PhotoUrl") & "' width='70px' height='80px' alt='" & rs("gcname") & " " & rs("gcJob")
……
……
& "' target='_blank' title='" & rs("title") & "'>" & left(trim(rs("title")),17) & "</a></div>"
end if
i=i+1
rs.MoveNext()
wend
txt.write mb_code
txt.close
%>这样就可以解决这个循环的问题了 展开
'创建对象实例
i=0
strSql = "select top 6 * from article where type='高层访谈'order by id desc"
set rs = conn.execute(strSql)
while (not rs.eof) and (not rs.bof)
if i=0 then
mb_code+CSTR(i)="<div class='specialconntent'><div class='specialpic'><img src='" & rs("PhotoUrl") & "' width='70px' height='80px' alt='" & rs("gcname") & " " & rs("gcJob") & "'/></div><div class='spicconntent'><a href='news.asp?id=" & rs("ID") & "' target='_blank' class='red' title='" & rs("gcJob") & "'>" & rs("gcname") & "</a><br /> <a href='news.asp?id=" & rs("ID") & "' target='_blank'>" & left(trim(rs("jianjie")),42) & "...</a></div></div>"
else
mb_code+CSTR(i)=)"<div class='speciallist'><img src='images/icon07.gif' width='10' height='10' /><a href='news.asp?id=" & rs("ID") & "' target='_blank' class='red' title='" & rs("gcJob") & "'>"& rs("gcname") &"</a>:<a href='news.asp?id=" & rs("ID") & "' target='_blank' title='" & rs("title") & "'>" & left(trim(rs("title")),17) & "</a></div>"
end if
i=i+1
rs.MoveNext()
wend
%><!--left_special2-->
<%
set fso=server.CreateObject("scripting.filesystemobject")
set txt=fso.CreateTextFile(server.MapPath("left_special2.html"))''2代表覆盖原文件
txt.write mb_code+CSTR(i)
txt.close
%>
mb_code+CSTR(i)=
现在语句是错误的,我要实现这种方式可以实现么,怎么实现,循环的输出
<%
set fso=server.CreateObject("scripting.filesystemobject")
set txt=fso.CreateTextFile(server.MapPath("left_special2.html"))''2代表覆盖原文件
'创建对象实例
i=0
strSql = "select top 6 * from article where type='高层访谈'order by id desc"
set rs = conn.execute(strSql)
while (not rs.eof) and (not rs.bof)
if i=0 then
mb_code=mb_code&"<div class='specialconntent'><div class='specialpic'><img src='" & rs("PhotoUrl") & "' width='70px' height='80px' alt='" & rs("gcname") & " " & rs("gcJob")
……
……
& "' target='_blank' title='" & rs("title") & "'>" & left(trim(rs("title")),17) & "</a></div>"
end if
i=i+1
rs.MoveNext()
wend
txt.write mb_code
txt.close
%>这样就可以解决这个循环的问题了 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询