国产探花免费观看_亚洲丰满少妇自慰呻吟_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) %>



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 普宁市| 丹凤县| 梁山县| 塔河县| 同仁县| 且末县| 睢宁县| 中西区| 凭祥市| 宁强县| 云梦县| 临邑县| 广元市| 南丹县| 灌云县| 罗甸县| 固安县| 多伦县| 南江县| 迭部县| 南开区| 日照市| 璧山县| 嘉善县| 尚义县| 唐河县| 来宾市| 延长县| 尚义县| 礼泉县| 凤城市| 浮梁县| 高州市| 西乌珠穆沁旗| 汉源县| 乐清市| 玛曲县| 萨迦县| 望江县| 桐城市| 南昌市|