我另外写了一个ShowAllPic.asp的程序上传到photo目录,直接访问数据库,得到PE_Photo这个表中的PhotoID为指定ID的栏中的PhotoUrl(存放同一ID下所有图片的地址)里面的内容。内容大致如下:
<!--#include file="../conn.asp"-->
<STYLE type=text/css>
a{text-decoration: none;} /* 链接无下划线,有为underline */
a:link {color: #333333;} /* 未访问的链接 */
a:visited {color: #333333;} /* 已访问的链接 */
a:hover{COLOR: #FF6600;} /* 鼠标在链接上 */
a:active {color: #333333;} /* 点击激活链接 */
BODY
{
FONT-SIZE: 9pt;background:url(Skin/adv43/ad_bg.gif);
text-decoration: none;
}
.pic{
border: 1px solid #cccccc;
}
</style>
<script language="javascript" type="text/javascript">
//改变图片大小
function resizepic(thispic)
{
if(thispic.width>650) thispic.width=650;
}
//无级缩放图片大小
function bbimg(o)
{
var zoom=parseInt(o.style.zoom, 10)||100;
zoom+=event.wheelDelta/12;
if (zoom>0) o.style.zoom=zoom+'%';
return false;
}
//双击鼠标滚动屏幕的代码
var currentpos,timer;
function initialize()
{
timer=setInterval ("scrollwindow ()",30);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos !=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
<%
'Everyday0905@163.com
'http://www.xiximm.com
dim PicID,PicUrl,PicNum,n,sql,Rs,PicUrl_1,PicUrl_2 '关键内容从这里开始
PicID=request("PicID") '获取页面请求的图片ID
sql="select * from PE_Photo where PhotoID = " &PicID '寻找数据库中相匹配的数据
set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open sql,conn,1,1
PicUrl=split(rs("PhotoUrl"),"$$$") '将从表中得到的PhotoUrl用$$$分隔开,存到PicUrl数组中,形如array(图片
地址1|a.jpg,图片地址2|b,jpg,图片地址3|c,jpg)
PicNum=UBound(PicUrl) '返回PicUrl数组的最大可用下标(+1即得到图片张数)
'response.write "第" & PicID & "一共有" & PicNum+1 & "张图片<br>"
for n=0 to PicNum '从第一个图片开始,循环显示
PicUrl_1=split(trim(PicUrl(n)),"|") '再次将 图片地址2|b,jpg 拆分为两部分,得到图片的地址
if UBound(PicUrl_1)=0 then '判断地址前面有没有"图片地址1"等说明,没有则加上“图片”字样
PicUrl_2=Array("图片",PicUrl_1(0))
else
PicUrl_2 =PicUrl_1
end if ' 将整理后的第N张图片的说明及地址存到数组PicUrl_2中
if left(PicUrl_2(1),7) = "http://" then '简单判断站内地址还是站外地址
else
PicUrl_2(1) = "UploadPhotos/" & PicUrl_2(1) '这里请改为你photo下面上传文件的文件夹
end if
response.write "<table width=20 align=center border=0 bgcolor=#ffffff cellpadding='0' cellspacing='0'>"
response.write "<tr><td width=10><img src='../Images/bg_0ltop.gif' width='10' height='10'></td>" '左上图片
response.write "<td height='10' background='../Images/bg_01.gif'></td>" '上背景
response.write "<td width=10><img src='../Images/bg_0rtop.gif' width='10' height='10'></tr>" '右上图片
response.write "<tr><td width='10' background='../Images/bg_03.gif'></td>" '左背景
response.write "<td align=center><img src='" & PicUrl_2(1) & "' class='pic' border=0 onscroll='bbimg(this)'
onload='resizepic(this)'>" '显示图片的html代码,可自己添加超级链接等
response.write "<br><br>第 <font color='red'>" & n+1 & "</font> 张图片:" & PicUrl_2(0) & "</td>"
':图片及说明
response.write "<td width='10' background='../Images/bg_04.gif'></td></tr>" '右背景
response.write "<tr><td width=10><img src='../Images/bg_0lbottom.gif' width='10' height='10'></td>" '左下图片
response.write "<td height='10' background='../Images/bg_02.gif'></td>" '下背景
response.write "<td width=10><img src='../Images/bg_0rbottom.gif' width='10' height='10'></tr>" '右下图片
response.write "</table><br> "
next
Rs.close
set Rs = nothing
%>
<iframe width='100%' name=web height='100%' scrolling='no' frameborder='0' src='{$InstallDir}Photo/ShowAllPic.asp?PicID={$PhotoID}' onload="this.height=web.document.body.scrollHeight+20" ></iframe>