asp问题:图片显示??? ( 积分: 25 )

  • 主题发起人 主题发起人 wxhn
  • 开始时间 开始时间
W

wxhn

Unregistered / Unconfirmed
GUEST, unregistred user!
<%
Response.Buffer = True
Response.Clear()
set rec=server.createobject(&quot;adodb.recordset&quot;)
sqlcmd=&quot;select * from pvrhotshows&quot;

rec.open sqlcmd,conn,1,1
response.contenttype = &quot;image/*&quot;
response.binarywrite rec(&quot;picture&quot;).getchunk(7500000)
'response.write rec(&quot;showid&quot;)
rec.close
set rec=nothing
set conn=nothing
%>
1,我要循环的把图片全部显示出来,按上面的代码只能显示一张图片。
3,如果上面再加个字段进去,就变成乱码了。
2,运行上面的代码,老是提示“文件下载”,重新输入代码编译又可以了。这是怎么回事啊
 
<%
Response.Buffer = True
Response.Clear()
set rec=server.createobject(&quot;adodb.recordset&quot;)
sqlcmd=&quot;select * from pvrhotshows&quot;

rec.open sqlcmd,conn,1,1
response.contenttype = &quot;image/*&quot;
response.binarywrite rec(&quot;picture&quot;).getchunk(7500000)
'response.write rec(&quot;showid&quot;)
rec.close
set rec=nothing
set conn=nothing
%>
1,我要循环的把图片全部显示出来,按上面的代码只能显示一张图片。
3,如果上面再加个字段进去,就变成乱码了。
2,运行上面的代码,老是提示“文件下载”,重新输入代码编译又可以了。这是怎么回事啊
 
<%
Response.Buffer = True
Response.Clear()
set rec=server.createobject(&quot;adodb.recordset&quot;)
sqlcmd=&quot;select * from pvrhotshows&quot;

rec.open sqlcmd,conn,1,3
response.contenttype = &quot;image/*&quot;
do while rec.eof=false
response.binarywrite rec(&quot;picture&quot;).getchunk(7500000) +&quot;<br>&quot;
rec.movenext
loop
'response.write rec(&quot;showid&quot;)
rec.close
set rec=nothing
set conn=nothing
%>
===================================
或看以下代码
<!--#include file=&quot;config/conn.asp&quot;-->
<html>
<head>
<title>aaaaaaaaaa</title>
<meta http-equiv=&quot;Content-Type&quot;
content=&quot;text/html;
charset=gb2312&quot;>
<link rel=&quot;stylesheet&quot;
href=&quot;css.css&quot;
type=&quot;text/css&quot;>
<script language=&quot;JavaScript&quot;
type=&quot;text/JavaScript&quot;>
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&amp;&amp;i<a.length&amp;&amp;(x=a)&amp;&amp;x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document;
if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
for(i=0;
i<a.length;
i++)
if (a.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x;
if(!d) d=document;
if((p=n.indexOf(&quot;?&quot;))>0&amp;&amp;parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);}
if(!(x=d[n])&amp;&amp;d.all) x=d.all[n];
for (i=0;!x&amp;&amp;i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&amp;&amp;d.layers&amp;&amp;i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x &amp;&amp;
d.getElementById) x=d.getElementById(n);
return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments;
document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src;
x.src=a[i+2];}
}
//-->
</script>
<style type=&quot;text/css&quot;>
<!--
.bd {
color: #316195;
font-family: &quot;宋体&quot;;
font-size: 9pt;
line-height: 150%;
}
.yedi {
font-family: &quot;宋体&quot;;
font-size: 9pt;
color: #000000;
text-decoration: none;
}
a:link {
color: #111111;
text-decoration: none;
}
a:visited {
color: #111111;
text-decoration: none;
}
a:hover {
color: #ff9900;
text-decoration: none;
}
-->
</style>
</head>
<body bgcolor=&quot;#0a61a4&quot;
topmargin=&quot;0&quot;
onLoad=&quot;MM_preloadImages('img/website_co_02.gif','img/website_co_04.gif',' img/website_co_06.gif','img/website_co_08.gif','img/website_co_10.gif','im g/website_co_11.gif')&quot;>
<script language=javascript>
function showpict(id)
{
window.open(&quot;showpict.asp?id=&quot;+id, &quot;NewWindow&quot;,&quot;toolbar =no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizab le=no,copyhistory=no,width=600,height=500,left=120,top=10&quot;);
}
</script>
</script>
<%
dim sql,rs,i,Page,iPage,id,j,k,l
sql=&quot;select * from pict order by id desc&quot;
set rs=server.createobject(&quot;adodb.recordset&quot;)
rs.open sql,conn,1,3
rs.PageSize = 16
Page=request(&quot;Page&quot;)
if trim(Page)=&quot;&quot;
then
Page=&quot;1&quot;
Page = CLng(Page)
If Page < 1 then
Page = 1
If Page > rs.PageCount then
Page = rs.PageCount

%>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 height=&quot;100%&quot;
width=778>
<TBODY>
<TR>
<TD
background=img/images-001.gif
width=6></TD>
<TD vAlign=top width=766> <table width=&quot;766&quot;
height=&quot;132&quot;
border=&quot;0&quot;
cellpadding=&quot;0&quot;
cellspacing=&quot;0&quot;>
<tr>
<td width=&quot;766&quot;
height=&quot;82&quot;
valign=&quot;top&quot;></td>
</tr>
<TR>
<TD

height=30><img src=&quot;img/menubg111.jpg&quot;
width=&quot;766&quot;
height=&quot;31&quot;
border=&quot;0&quot;
usemap=&quot;#Map&quot;></TD>
</TR>
<TD height=118 background=&quot;img/8.jpg&quot;> </TD>
</table>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=766 height=&quot;423&quot;>
<TBODY>
<TR>
<TD bgColor=#f1f1f1 height=423 vAlign=top width=179 rowspan=&quot;3&quot;> <TABLE border=0 cellPadding=0 cellSpacing=0 width=&quot;100%&quot;>
<TBODY>
<TR>
<TD

height=24><img src=&quot;img/zbbb.jpg&quot;
width=&quot;188&quot;
height=&quot;25&quot;></TD>
</TR>
</TBODY>
</TABLE>
<TABLE width=188 height=&quot;546&quot;
border=0 align=&quot;center&quot;
cellPadding=0 cellSpacing=0>
<TBODY>
<TR vAlign=top>
<TD width=188 height=&quot;546&quot;
background=img/aboutus_bk_02.gif>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=188>
<TBODY>
<TR>
<TD vAlign=top><IMG height=9
src=&quot;img/aboutus_menu_01.gif&quot;
width=188></TD>
</TR>
<TR>
<TD vAlign=top><A
href=&quot;gsyj.asp&quot;
onmouseout=MM_swapImgRestore()
onmouseover=&quot;MM_swapImage('Image15','','img/website_co_02.gif',1)&quot;><IMG
border=0 height=36 name=Image15
src=&quot;img/website_co_01.gif&quot;
width=188></A></TD>
</TR>
<TR>
<TD vAlign=top><a
href=&quot;hyxw.asp&quot;
onMouseOut=MM_swapImgRestore()
onMouseOver=&quot;MM_swapImage('Image23','','img/website_co_04.gif',1)&quot;><img
src=&quot;img/website_co_03.gif&quot;
name=Image23
width=188 height=36
border=0></a></TD>
</TR>
<TR>
<TD vAlign=top><A
href=&quot;zytz.asp&quot;
onmouseout=MM_swapImgRestore()
onmouseover=&quot;MM_swapImage('Image10','','img/website_co_06.gif',1)&quot;><IMG
border=0 height=36 name=Image10
src=&quot;img/website_co_05.gif&quot;
width=188></A></TD>
</TR>
<TR>
<TD vAlign=top><a href=&quot;lxwm.asp&quot;
onMouseOut=MM_swapImgRestore()
onMouseOver=&quot;MM_swapImage('Image141','','img/website_co_08.gif',1)&quot;><img
border=0 height=36 name=Image141
src=&quot;img/website_co_07.gif&quot;
width=188></a></TD>
</TR><TR>
<TD height=&quot;36&quot;
vAlign=top><A href=&quot;#&quot;
onmouseout=MM_swapImgRestore()
onmouseover=&quot;MM_swapImage('Image109','','img/website_co_11.gif',1)&quot;><IMG
border=0 height=36 name=Image109
src=&quot;img/website_co_12.gif&quot;
width=188></A></TD>
</TR>
<TR>
<TD height=&quot;36&quot;
vAlign=top><A href=&quot;zlxz.asp&quot;
onmouseout=MM_swapImgRestore()
onmouseover=&quot;MM_swapImage('Image100','','img/website_co_10.gif',1)&quot;><IMG
border=0 height=36 name=Image100
src=&quot;img/website_co_09.gif&quot;
width=188></A></TD>
</TR>

<TR>
<TD vAlign=top><IMG height=23
src=&quot;img/website_main_01.gif&quot;
width=188></TD>
</TR>
<TR>
<TD height=&quot;18&quot;
vAlign=top>&amp;nbsp;</TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
</TBODY>
</TABLE></TD>
<TD bgColor=#999999 width=1 height=&quot;423&quot;
rowspan=&quot;3&quot;></TD>
<TD bgColor=#ffffff vAlign=top width=586 height=&quot;35&quot;> 
<% if rs.eof=false and rs.bof=false then
rs.AbsolutePage = Page
For iPage = 1 To 4
%>
<table width=&quot;490&quot;
height=&quot;94&quot;
border=&quot;0&quot;
cellpadding=&quot;0&quot;
cellspacing=&quot;0&quot;>
<tr>
<%for j=1 to 4
if rs.eof=true then
exit for
id=&quot;&quot;&amp;rs(&quot;id&quot;)
%>
<td width=&quot;1&quot;
height=&quot;1&quot;
valign=&quot;top&quot;> <a href=&quot;#&quot;
onClick=&quot;showpict('<%=id%>')&quot;><img src=&quot;ShowImageFromData.asp?id=<%=id%>&quot;
width=&quot;137&quot;
height=&quot;122&quot;
border=&quot;1&quot;
bordercolorlight=&quot;#5c7bad&quot;
bordercolordark=&quot;#ffffff&quot;></a>
</td>
<%

k=k+1
if k>=16 then
exit for
rs.movenext
if rs.eof=true then
exit for
next
%>
</tr>
<%
next
end if
%>
</table></TD>
<tr>
<TD bgColor=#ffffff vAlign=top width=586 height=&quot;15&quot;>
<p align=&quot;right&quot;><font color=&quot;#0000FF&quot;
size=&quot;2&quot;
face=&quot;宋体&quot;>共[<%=rs.recordcount%>
]条记录,每页20条记录,共[<%=rs.pagecount%>
]页。</font></TD>
</tr>
<tr>
<TD bgColor=#ffffff vAlign=top width=586 height=&quot;514&quot;>
<div ALIGN=&quot;center&quot;>
<center>
<table height=&quot;37&quot;
style=&quot;font-family: 宋体;
font-size: 10pt&quot;>
<font color=&quot;#0000FF&quot;
size=&quot;2&quot;
face=&quot;宋体&quot;>
<form ACTION=&quot;<%=Myself%>&quot;
METHOD=&quot;POST&quot;>
<tr>
<td height=&quot;33&quot;>
<p><%If Page <> 1 then
' 如果不是位于第一页%>
<a href=&quot;<%=Myself%>?Page=1&quot;>第一页</a>
<a HREF=&quot;<%=Myself%>?Page=<%=(Page-1)%>&quot;>上一页</a>
<%
End If
If Page <> rs.PageCount then
' 如果不是位于最后一页
%>
<a HREF=&quot;<%=Myself%>?Page=<%=(Page+1)%>&quot;>下一页</a>
<a HREF=&quot;<%=Myself%>?Page=<%=rs.PageCount%>&quot;>最后一页</a>
<% End If %>
输入页次:<input NAME=&quot;Page&quot;
SIZE=&quot;3&quot;
CLASS=&quot;s01&quot;>
页次:<%=Page%>
/</font><font COLOR=&quot;Red&quot;
SIZE=&quot;2&quot;
face=&quot;宋体&quot;><%=rs.PageCount%>
</font></p>
<p> </td>
</tr>
</form>
</table>
</center>
</div>
<p> </TD>
</tr>
</TBODY>

</TABLE>

<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<table width=&quot;100%&quot;
border=&quot;0&quot;
cellspacing=&quot;0&quot;
cellpadding=&quot;0&quot;>
<tr>
<td><TABLE border=0 cellPadding=0 cellSpacing=0 width=766>
<TBODY>
<TR>
<TD bgColor=#e3e3e3 height=5></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<tr>
<td><TABLE border=0 cellPadding=0 cellSpacing=0 width=766>
<TBODY>
<TR>
<TD bgColor=#ffffff height=1></TD>
</TR>
<TR>
<TD bgColor=#1a83cb height=6></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
<tr>
<td><TABLE border=0 cellPadding=5 cellSpacing=0 width=766>
<TBODY>
<TR>
<TD background=img/aboutus_bk_02.gif > <DIV align=center>
<p class=&quot;yedi&quot;
><a href=&quot;index.asp&quot;>回到首页</a> |<a href=&quot;index.asp&quot;>
公司简介</a> | 联系我们<BR>
<br>
Copyright(C) </p>
</DIV></TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
</table></TD>
<TD
background=img/images-002.gif
width=6></TD>
</TR>
</TBODY>
</TABLE>
<map name=&quot;Map&quot;>
<area shape=&quot;rect&quot;
coords=&quot;254, 6, 300, 28&quot;
href=&quot;index.asp&quot;>
<area shape=&quot;rect&quot;
coords=&quot;326, 6, 394, 24&quot;
href=&quot;zhiye.asp&quot;>
<area shape=&quot;rect&quot;
coords=&quot;414, 4, 482, 26&quot;
href=&quot;zhaobaioxx.asp&quot;>
<area shape=&quot;rect&quot;
coords=&quot;506, 7, 570, 27&quot;
href=&quot;zbgs.asp&quot;>
<area shape=&quot;rect&quot;
coords=&quot;602, 6, 662, 28&quot;
href=&quot;zcfg.asp&quot;>
<area shape=&quot;rect&quot;
coords=&quot;690, 6, 760, 28&quot;
href=&quot;addyhly.asp&quot;>
</map>
</body>
</html>
=========================
ShowImageFromData.asp
<!--#include file=&quot;config/conn.asp&quot;-->
<%
dim sql,id,rs
id =request(&quot;id&quot;)
if id = &quot;&quot;
then
response.end
sql = &quot;select * from pict where id=&quot;
&amp;
trim(id)
set rs=server.createobject(&quot;adodb.recordset&quot;)
rs.open sql,conn,1,3
if isnull(rs(0))=false then
response.ContentType =&quot;image/*&quot;
' rs(&quot;picttype&quot;)
response.BinaryWrite rs(&quot;pict&quot;)
else
response.write &quot;暂无图片&quot;
end if
rs.close
set rs = nothing
%>
 
接受答案了.
 
后退
顶部