ASP, 提取数据库中的内容循环赋值给数组
数据库的内容为:<%setrs=Server.CreateObject("ADODB.recordset")rs.open"selecttop6id,img,txt,ur...
数据库的内容为:
<%
set rs=Server.CreateObject("ADODB.recordset")
rs.open "select top 6 id,img,txt,url from picshow order by id desc",conn,1,1
IF rs.EOF and rs.BOF THEN
RESPONSE.Write"<BR><BR> 暂时还没有信息... <br>"
ELSE
for i=1 to 6%>
--------这里是循环,提取数据库中的内容
<%Rs.movenext
If rs.eof Then exit For
Next
End If
rs.close%>
问题是如何把数据库中的内容放到下面的数组中,最好使用循环语句!
<script>
var isPause = false;
var scrollImg = new Array();
var scrollTxt = new Array();
var scrollUrl = new Array();
scrollImg[0]="http://pic.tiexue.net/pics/2008_4_30_57526_7257526.gif";
scrollTxt[0]="5.1让我们一起护圣火";
scrollUrl[0]="http://zh.sdo.com/Project/51fire/index.html";
scrollImg[1]="http://pic.tiexue.net/pics/2008_5_4_77612_7277612.jpg";
scrollTxt[1]="圣火澳门传递我的所见所闻";
scrollUrl[1]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[2]="http://pic.tiexue.net/pics/2008_5_4_77603_7277603.jpg";
scrollTxt[2]="俄罗斯彼得堡学生5月3日迎奥运集会";
scrollUrl[2]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[3]="http://pic.tiexue.net/pics/2008_5_4_77586_7277586.jpg";
scrollTxt[3]="难得一见的越南民警抓嫖图!";
scrollUrl[3]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[4]="http://pic.tiexue.net/pics/2008_5_4_77568_7277568.jpg";
scrollTxt[4]="解放巴黎全过程 高卢鸡又雄起了";
scrollUrl[4]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[5]="http://pic.tiexue.net/pics/2008_5_1_63285_7263285.jpg";
scrollTxt[5]="保卫意大利总统的女人们";
scrollUrl[5]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
</script> 展开
<%
set rs=Server.CreateObject("ADODB.recordset")
rs.open "select top 6 id,img,txt,url from picshow order by id desc",conn,1,1
IF rs.EOF and rs.BOF THEN
RESPONSE.Write"<BR><BR> 暂时还没有信息... <br>"
ELSE
for i=1 to 6%>
--------这里是循环,提取数据库中的内容
<%Rs.movenext
If rs.eof Then exit For
Next
End If
rs.close%>
问题是如何把数据库中的内容放到下面的数组中,最好使用循环语句!
<script>
var isPause = false;
var scrollImg = new Array();
var scrollTxt = new Array();
var scrollUrl = new Array();
scrollImg[0]="http://pic.tiexue.net/pics/2008_4_30_57526_7257526.gif";
scrollTxt[0]="5.1让我们一起护圣火";
scrollUrl[0]="http://zh.sdo.com/Project/51fire/index.html";
scrollImg[1]="http://pic.tiexue.net/pics/2008_5_4_77612_7277612.jpg";
scrollTxt[1]="圣火澳门传递我的所见所闻";
scrollUrl[1]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[2]="http://pic.tiexue.net/pics/2008_5_4_77603_7277603.jpg";
scrollTxt[2]="俄罗斯彼得堡学生5月3日迎奥运集会";
scrollUrl[2]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[3]="http://pic.tiexue.net/pics/2008_5_4_77586_7277586.jpg";
scrollTxt[3]="难得一见的越南民警抓嫖图!";
scrollUrl[3]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[4]="http://pic.tiexue.net/pics/2008_5_4_77568_7277568.jpg";
scrollTxt[4]="解放巴黎全过程 高卢鸡又雄起了";
scrollUrl[4]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
scrollImg[5]="http://pic.tiexue.net/pics/2008_5_1_63285_7263285.jpg";
scrollTxt[5]="保卫意大利总统的女人们";
scrollUrl[5]="http://bbs.tiexue.net/ShowPicClass_53_1.html";
</script> 展开
1个回答
展开全部
呵呵,你这个是flash六图轮换,没必要作数组,在<script></script>中间直接循环就行了,我之前做过一个,希望能对你有所帮助。
需要该flash的话我发给你
<script type="text/javascript">
<%dim ij
ij=0
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 5 id,title,imgprev from Conews where imgprev<>'' and Publick=True order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "<center>目前还没有新闻图片!</center>"
else
do while not rs.eof
ij=ij+1
%>
<%
response.write "imgUrl"&ij&"="&chr(34)&"http://localhost/"&rs("ImgPrev")&""&chr(34)&""&chr(59)&""&vbCrLf
response.write "imgtext"&ij&"="&chr(34)&""&rs("title")&""&chr(34)&""&vbCrLf
response.write "imgLink"&ij&"=escape("&chr(34)&"newsinfo.asp?id="&rs("Id")&""&chr(34)&")"&chr(59)&""&vbCrLf
'response.end
%>
<% if ij>=5 then exit do
rs.movenext
loop
end if
rs.close
set rs=nothing%>
var focus_width=170
var focus_height=150
var text_height=18
var swf_height = focus_height+text_height
var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5
var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5
var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('</object>');
</script>
需要该flash的话我发给你
<script type="text/javascript">
<%dim ij
ij=0
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 5 id,title,imgprev from Conews where imgprev<>'' and Publick=True order by id desc",conn,1,1
if rs.eof and rs.bof then
response.write "<center>目前还没有新闻图片!</center>"
else
do while not rs.eof
ij=ij+1
%>
<%
response.write "imgUrl"&ij&"="&chr(34)&"http://localhost/"&rs("ImgPrev")&""&chr(34)&""&chr(59)&""&vbCrLf
response.write "imgtext"&ij&"="&chr(34)&""&rs("title")&""&chr(34)&""&vbCrLf
response.write "imgLink"&ij&"=escape("&chr(34)&"newsinfo.asp?id="&rs("Id")&""&chr(34)&")"&chr(59)&""&vbCrLf
'response.end
%>
<% if ij>=5 then exit do
rs.movenext
loop
end if
rs.close
set rs=nothing%>
var focus_width=170
var focus_height=150
var text_height=18
var swf_height = focus_height+text_height
var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5
var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5
var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('</object>');
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询