首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

常用的广告代码,怎么实现从数据库中取值

2012-02-26 
常用的广告代码,如何实现从数据库中取值。scripttype text/javascript imgUrl1 news/1.jpg imgtex

常用的广告代码,如何实现从数据库中取值。
<script   type= "text/javascript ">
imgUrl1= "news/1.jpg ";
imgtext1= "新闻动态1 "
imgLink1=escape( "index.html ");
imgUrl2= "news/2.jpg ";
imgtext2= "新闻动态2 "
imgLink2=escape( "index.html ");
imgUrl3= "news/3.jpg ";
imgtext3= "新闻动态3 "
imgLink3=escape( "index.html ");
imgUrl4= "news/4.jpg ";
imgtext4= "新闻动态4 "
imgLink4=escape( "index.html ");
imgUrl5= "news/5.jpg ";
imgtext5= "新闻动态5 "
imgLink5=escape( "index.html ");
var   focus_width=250
var   focus_height=160
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= "img/focus2.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>
-------------------------------------
如何将imgUrl等变量的值从数据库中取值?


[解决办法]
imgUrl1= "news/1.jpg ";
imgtext1= "新闻动态1 "
imgLink1=escape( "index.html ");
imgUrl2= "news/2.jpg ";
imgtext2= "新闻动态2 "
imgLink2=escape( "index.html ");
imgUrl3= "news/3.jpg ";
imgtext3= "新闻动态3 "
imgLink3=escape( "index.html ");
imgUrl4= "news/4.jpg ";
imgtext4= "新闻动态4 "
imgLink4=escape( "index.html ");
imgUrl5= "news/5.jpg ";
imgtext5= "新闻动态5 "
imgLink5=escape( "index.html ");

这一段都去了~
改成从数据库里面读取的~

<%
Set Rs = Server.CreateObject( "ADODB.RecordSet ")
Rs.Open "Select * From [Ads_List] ",Conn,1,1
Do While Not Rs.Eof
imgUrl = imgUrl & Rs( "AL_Pic ") & "| "
imgText = imgText & Rs( "AL_Title ") & "| "
imgLink = imgLink & Rs( "AL_Link ") & "| "
Rs.MoveNext
Loop
if imgUrl <> " " then
imgUrl = Left(imgUrl,len(imgUrl) -1)
imgText = Left(imgText,len(imgText) -1)
imgLink = Left(imgLink,len(imgLink) -1)


end if
%>
var pics = <%=imgUrl%> ;
var links = <%=imgLink%> ;
var texts = <%=imgText%> ;
[解决办法]
我做过直接写文件,代码发给你参考一下,FLASH你可向我要,MSN:g_haihua@163.com
(一次回复太长分两段)

<!--#include Virtual = "/ref/flash.inc "-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml "> <!-- InstanceBegin template= "/Templates/manage.dwt.asp " codeOutsideHTMLIsLocked= "false " -->
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<!--#include Virtual = "/manage/inc/islogin.asp "-->
<%
titleTxt=Request.Cookies( "manage_nav ")
%>
<title> <%=titleTxt%> </title>
<link href= "/manage/css/admin.css " rel= "stylesheet " type= "text/css " />
</head>
<body onload= "LoadFinish() ">
<%
Response.Write( " <div id= " "LoadProcess " " style= " "position:absolute; left:35%; top:111px; padding:8px; border:1px solid #000000; z-index:1; visibility: visible " "> "&vbcrlf)
Response.Write( " <img src= " "/manage/images/progress_circle.gif " " hspace= " "3 " " align= " "absmiddle " " /> 请稍候,正在加载数据...... </div> "&vbcrlf)
Response.Flush()
%>
<!--后台管理头部-->
<!--#include Virtual = "/manage/inc/admin_head.asp "-->

<!--后台管理主体-->
<div id= "maincontent ">

<table width= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "188 " valign= "top " class= "menu_right_line ">
<!--左栏导航-->
<!--#include Virtual = "/manage/inc/admin_left_menu.asp "-->
</td>
<td align= "left " valign= "top ">
<!--右侧主体部分-->
<div id= "right ">
<!--#include Virtual = "/manage/inc/admin_nav_immovable.asp "-->
<div id= "page_corr_nav ">
<strong> 操作: </strong>

<!--页面导航位置-->
<!-- InstanceBeginEditable name= "page_nav " -->
<!--请添加导航链接-->
没有相关操作
<!-- InstanceEndEditable -->

</div>

<!--页面主体从这里开始-->

<!-- InstanceBeginEditable name= "page_body " -->
<!--清添加页面主体内容-->
<%
'收集内容进行修改
action = Request.QueryString( "action ")
If action = "edit " then
Dim Ad
txt01 = Request.Form( "txt01 ")
txt02 = Request.Form( "txt02 ")
txt03 = Request.Form( "txt03 ")
txt04 = Request.Form( "txt04 ")
txt05 = Request.Form( "txt05 ")

img_001 = Request.Form( "img_001 ")
img_002 = Request.Form( "img_002 ")
img_003 = Request.Form( "img_003 ")
img_004 = Request.Form( "img_004 ")
img_005 = Request.Form( "img_005 ")

url_001 = Request.Form( "url_001 ")
url_002 = Request.Form( "url_002 ")
url_003 = Request.Form( "url_003 ")
url_004 = Request.Form( "url_004 ")


url_005 = Request.Form( "url_005 ")

'配置成功生成文件
'基本配置
Ad_p = " < "& "% "&vbcrlf
Ad_p = Ad_p& "Const flash_txt01= " " "&Replace(txt01, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_txt02= " " "&Replace(txt02, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_txt03= " " "&Replace(txt03, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_txt04= " " "&Replace(txt04, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_txt05= " " "&Replace(txt05, " " " ", " " " " " ")& " " " "&vbcrlf

Ad_p = Ad_p& "Const flash_img_001= " " "&Replace(img_001, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_img_002= " " "&Replace(img_002, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_img_003= " " "&Replace(img_003, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_img_004= " " "&Replace(img_004, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_img_005= " " "&Replace(img_005, " " " ", " " " " " ")& " " " "&vbcrlf

Ad_p = Ad_p& "Const flash_url_001= " " "&Replace(url_001, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_url_002= " " "&Replace(url_002, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_url_003= " " "&Replace(url_003, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_url_004= " " "&Replace(url_004, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "Const flash_url_005= " " "&Replace(url_005, " " " ", " " " " " ")& " " " "&vbcrlf
Ad_p = Ad_p& "% "& "> "&vbcrlf

'生成FLash配置参数
set fs=server.CreateObject( "Scripting.FileSystemObject ")
set file=fs.CreateTextFile(Server.mappath( "..\..\Ref\flash.inc "))
file.write Ad_p
file.close
set file=nothing

'生成flash广告代码
Ad = Ad& "// JavaScript Document "&vbcrlf
Ad = Ad& "var tmpHTML = ' '; "&vbcrlf

Ad = Ad& "tmpHTML = tmpHTML + ' <OBJECT classid= " "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 " " codebase= " "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 " " WIDTH= " "357 " " HEIGHT= " "179 " " id= " "flashview " " ALIGN= " " " "> ' "&vbcrlf


Ad = Ad& "tmpHTML = tmpHTML + ' <PARAM NAME=movie VALUE= " "swf/flashview.swf? ' "&vbcrlf

Ad = Ad& "tmpHTML = tmpHTML + 'txt01= "&txt01& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&txt02= "&txt02& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&txt03= "&txt03& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&txt04= "&txt04& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&txt05= "&txt05& " ' "&vbcrlf

Ad = Ad& "tmpHTML = tmpHTML + '&img_001= "&img_001& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&img_002= "&img_002& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&img_003= "&img_003& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&img_004= "&img_004& " ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&img_005= "&img_005& " ' "&vbcrlf

Ad = Ad& "tmpHTML = tmpHTML + '&url_001=javascript:goURL(1); ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&url_002=javascript:goURL(2); ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&url_003=javascript:goURL(3); ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&url_004=javascript:goURL(4); ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + '&url_005=javascript:goURL(5); ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + ' " "/> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#C0E2D2> <EMBED src= " "swf/flashview.swf " " quality=high bgcolor=#C0E2D2 WIDTH= " "357 " " HEIGHT= " "179 " " ALIGN= " " " " TYPE= " "application/x-shockwave-flash " " PLUGINSPAGE= " "http://www.macromedia.com/go/getflashplayer " "> </EMBED> ' "&vbcrlf
Ad = Ad& "tmpHTML = tmpHTML + ' </OBJECT> ' "&vbcrlf

Ad = Ad& "printHTML(tmpHTML); "&vbcrlf

Ad = Ad& "function goURL(str) { "&vbcrlf

Ad = Ad& "var url_001 = " " "&url_001& " " "; "&vbcrlf
Ad = Ad& "var url_002 = " " "&url_002& " " "; "&vbcrlf
Ad = Ad& "var url_003 = " " "&url_003& " " " "&vbcrlf
Ad = Ad& "var url_004 = " " "&url_004& " " "; "&vbcrlf
Ad = Ad& "var url_005 = " " "&url_005& " " "; "&vbcrlf

Ad = Ad& "location.href=eval( " "url_00 " "+str); "&vbcrlf
Ad = Ad& "} "&vbcrlf

Ad = Ad& "function printHTML(str) { "&vbcrlf
Ad = Ad& "var strHTML = str; "&vbcrlf
Ad = Ad& "document.write(strHTML); "&vbcrlf
Ad = Ad& "} "&vbcrlf
set fs=server.CreateObject( "Scripting.FileSystemObject ")
set file=fs.CreateTextFile(Server.mappath( "..\..\Ad\Ad_cycle.js "))
file.write Ad
file.close
set file=nothing

call PopUpMsg( "配置成功! ",0, "flash.asp ")
end if
%>

[解决办法]
谢谢楼上的。我自己解决了。刚想到了解决思路,试了一下,可以达到想要的效果。就是不知道代码执行率和稳定性之类的好不好。

热点排行