| 域名空间 下载中心 社区论坛 信息公告 MY小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | Q Q 专栏 | 建站经验 | 在线工具 | 站长Club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
建立一个广告交换及跟踪系统http://www.iyit.net 日期:2006-6-7 10:50:26 来源:不详 点击: |
tblBanners: bID - auto number (banner ID) bBanner - text (image file) bUsedViews - number (# of views the banner has received) bTotalViews - number (# of impressions the vendor has paid for) bClicks - number (# of clicks the banner has received) bURL - text (URL of the site) bShow - yes/no (used to show and hide banners) vID - number (vendor ID) tblVendors: vID - autonumber (vendor ID - links to tblBanners.vID) vName - text (Vendor's name) etc.......... Now that the database is set up, we need to randomly display the banner on our pages and increment the 'views' by 1: First you need to open your database connection on the page you want your banner to be viewed on. We use a DSN-less connection; you can find it at the following address: http://www.askasp.com/toolbox.asp?Expand=True&ID=2#tool Here is what the SQL might look like: 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]));" In the above SQL, we are checking for the 'bShow' flag to be True, and that the UsedViews is less than the 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) %> 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:如何制作无状态的ASP组件 下一篇:XMLHTTP+javascript+Asp写得聊天室,无刷新实现(六) 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 最新更新 | 热点排行 | 推荐新闻 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 友情链接 | ||||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||