注册 登录
编程论坛 ASP技术论坛

大家帮个忙,帮我取一下图片地址

yuzhou_2012 发布于 2012-07-10 12:09, 410 次点击
只有本站会员才能查看附件,请 登录

如果c_parent = 0 显示的图片为当前图片显示的ID,如果c_parnet <>0 图片显示的为其父的ID ,列如 c_parent=2 它的图片显示为"关于我们"这一栏的图片,大家帮忙给我写一下,非常感谢

<%Set rs = Server.CreateObject("ADODB.Recordset")
if c_parent = 0 then
rs.open "select * from cms_channel where id="&request("id"),conn,1,3
if  not rs.eof then
response.write("<img src="&rs("upload_pic")&">")
end if
rs.close
end if
%>
3 回复
#2
yms1232012-07-10 16:20
rs.open "select * from cms_channel where id="&request("id"),conn,1,3 、
不等于0读取的时候这里改为
rs.open "select * from cms_channel where id="&c_parent,conn,1,3
不就读取到了吗?
#3
yuzhou5182012-07-11 09:30
谢谢了
#4
netlin2012-07-14 06:27
楼主,帮你做了一些修改,你试一下,看能否满足要求?

<%Set rs = Server.CreateObject("ADODB.Recordset")
if c_parent = 0 then
'rs.open "select * from cms_channel where id="&request("id"),conn,1,3
rs.open "select case when a.c_parent=0 then a.upload_pic else b.upload_pic end as upload_pic from cms_channel a left join cms_channel b on a.c_parent=b.id  and a.id="&request("id"),conn,1,3
if  not rs.eof then
response.write("<img src="&rs("upload_pic")&">")
end if
rs.close
end if
%>
1