国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

廣告播放和跟蹤系統的制作

2019-11-18 22:15:10
字體:
來源:轉載
供稿:網友
首先你需要一個數據庫放置你的廣告,我們共用了2個表: blBanners 和 tblVendors表:
tblBanners結構表如下:
bID - auto number (廣告ID)
bBanner - text (圖像文件)
bUsedViews - number (# 標準的廣告顯示次數)
bTotalViews - number (# of imPRessions the vendor has paid for)
bClicks - number (# 標準的廣告點擊次數)
bURL - text (網站URL)
bShow - yes/no (用來標識廣告是顯示還是隱藏)
vID - number (賣主 ID)

tblVendors表結構如下:
vID - autonumber (賣主 ID - 鏈到tblBanners.vID)
vName - text (賣主的名字)
etc..........

第一步

現在,這個數據庫已經建立了,你需要有隨機地在我們的網頁中顯示廣告并且計算顯示次數。:
DSN鏈接不講了,如果不會,你可以到以下地址看看:
http://www.askasp.com/toolbox.asp?Expand=True&ID=2#tool

如果是SQL,可以采用下面的相似語句:

SQL = "SELECT tblBanners.bID, tblBanners.bImage, tblBanners.bUsedViews, tblBanners.bLastViewed "
SQL = SQL & "FROM tblBanners "
SQL = SQL & "WHERE (((tblBanners.bShow)=True) AND ((tblBanners.bTotalViews)>[tblBanners].[bUsedViews]));"

在上面的SQL語句中,只有當bShow標志是True而且UsedViews(顯示客戶廣告次數)小于TotalViews(客戶總顯示廣告次數)的
記錄才作選取(下面不翻譯了,深夜了:)。

Now that we have all of the banners that we can display, we need to display a random one. We can do this
by grabbing the total number of banners, moving to the first record, and the moving to a random number,
for example:


Dim rndMax, rndNumber

Randomize

rndMax = Int(RecordSet.RecordCount)
rndNumber = Int(RND * rndMax)

RecordSet.Move rndNumber


Now that we have moved to our random banner, we now need to display the banner on our page (I am sure you
know how to do that, so I wont bore you with the details). However, Instead of using the banner's URL in
the link, we are going to use a redirect page so we can count the clicks. All we need to do is use the
banner ID in the HREF tag, for example:

a href="redirect.asp?ID=<%= BANNER ID %>"

Now that we have the link set up, we can move on to our redirect.asp page. On this page, we are going to
grab the ID that we are passing in the Query String, and grabbing the RecordSet that matches. Once we have
the RecordSet, we can grab the banner's URL, increase the Clicks by 1, and send the user to the
destination URL. Below is the code for the redirect.asp page:

<%
If Request.QueryString("ID") = "" Then
Response.Redirect("default.asp")
End If

Dim varSiteToRedirect, varURLToRedirect

varSiteToRedirect = Int(Request.QueryString("ID"))


SQL = "SELECT tblBanners.bID, tblBanners.bURL, tblBanners.bClicks "
SQL = SQL & "FROM tblBanners "
SQL = SQL & "WHERE (((tblBanners.bID)=" & varSiteToRedirect & "));"

varDatabaseName = "ask_asp_data.mdb"
%>

<!--#include file="common/data_conn_open.asp"-->

<%
If Not RecordSet.BOF Then
RecordSet.MoveFirst
End If

varURLToRedirect = RecordSet.Fields("bURL")

RecordSet.Fields("bClicks") = (RecordSet.Fields("bClicks") + 1)
RecordSet.Update
%>

<!--#include file="common/data_conn_close.asp"-->

<% Response.Redirect(varURLToRedirect) %>



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 曲松县| 古蔺县| 日土县| 绥中县| 图木舒克市| 玉山县| 康定县| 鄂温| 沁水县| 鞍山市| 安义县| 利川市| 仪陇县| 玉门市| 察哈| 中牟县| 屯门区| 许昌市| 许昌县| 三原县| 津市市| 延津县| 天津市| 高青县| 斗六市| 修水县| 察雅县| 长治市| 海城市| 霸州市| 西峡县| 云和县| 铁力市| 汤原县| 马关县| 东乌珠穆沁旗| 白河县| 翁牛特旗| 定边县| 吴旗县| 手机|