我要表达的意思是如果该广告位无图片或者广告到期,则显示“虚位以待”的图片,
代码是这样的,其中adend是指广告到期的时间
<!--#include file="conn.asp"-->
<%
set rs=server.creatobject("adodb.recordset")
sql="select * from ad where number='0001'"
rs.open sql,conn,1,1
if not rs.eof and now()< rs("adend")then
%><img height="90" width="345" scr="<%=rs("pic")%>"/><%else%>><img height="90" width="345" scr"123.gif"/><%end if%>
这样写代码有问题吗,为什么要提示我发生意外?
刚才一时心急打错了,源代码是这样下的
<%
set rs1=server.CreateObject("adodb.recordset")
sql1="select * from ad where adsite='0003'"
rs1.open sql1,conn,1,1
if not rs1.eof and now()<rs1("adend") then
if rs1("link")="1" then
response.Write"<a href="&rs1("web")&">"
elseif rs1("link")="2" then
response.Write"<a href=model.asp?id="&rs1("id")&">"
elseif rs1("link")="3" then
response.Write"<a href="&rs1("adpage")&">"
end if
response.Write"<img height=90 width=245 src="&rs1("pic")&" border=0 />"
else
response.Write"<img height=90 width=245 src=images/upload/2008101122552444554.jpg />"
end if%>
程序代码:
<%
set rs1=server.CreateObject("adodb.recordset")
sql1="select * from ad where adsite='0003'"
rs1.open sql1,conn,1,1
if (not rs1.eof) and (now()<rs1("adend")) then ' 严谨的代码要打括号的。
if rs1("link")="1" then ' 建议用Select Case语句代替
response.Write"<a href="&rs1("web")&">"
elseif rs1("link")="2" then
response.Write"<a href=model.asp?id="&rs1("id")&">"
elseif rs1("link")="3" then
response.Write"<a href="&rs1("adpage")&">"
end if
response.Write"<img height=90 width=245 src="&rs1("pic")&" border=0 />"
else ' 逻辑有错!!运行到这里,应当有rs1.eof or (now>=rs1("adend")) 你觉得合适吗?
response.Write"<img height=90 width=245 src=images/upload/2008101122552444554.jpg />"
end if
%>