Advertising rotation system

Source: Internet
Author: User
Tags dsn

CF does not provide advertisement components like ASP, but this does not mean that a powerful advertisement system cannot be created. Here I put a simple advertisement rotation system, it is also used in my CCF Forum. function, including the number of displays and the number of clicks. it is easy to expand on this basis and can be displayed in different categories. The following code only shows large advertisements. I just want to give you a chance to make a more powerful advertising system.

<! --- Determine whether there is Address transfer --->
<Cfif not IsDefined ("URL. ADID")>
<! --- Display advertisement by default --->
<Cflock timeout = "10">

<Cfparam name = "Application. AD" TYPE = "string" DEFAULT = ">
  
<CFIF ListLen (Application. AD) EQ 0>
<Cfquery name = "getID" datasource = "# DSN #">
Select adid from ad
</Cfquery>
   
<CFSET Application. AD = ValueList (getID. ADID)>
</CFIF>
  
<CFSET ThisAdID = ListGetAt (Application. AD, 1)>
<CFSET Application. AD = ListDeleteAt (Application. AD, 1)>
</CFLOCK>

<Cfquery name = "ad" datasource = "# DSN #">
Select * from ad
Where adid = '# ThisAdID #'
</Cfquery>

<! --- Update display times --->

<Cfset adshow = AD. SHOW + 1>

<Cfquery name = "updateshow" datasource = "# DSN #">
UPDATE AD
SET show = '# ADSHOW #'
Where ADID = '# AD. ADID #'
</Cfquery>

<! --- Display advertisement --->
<A href = "javascript: location. reload ()"> refresh </a> <p>
<Cfoutput query = "ad">
<A href = "ad. cfm? ADID = # URLEncodedFormat (ADID) # "title =" # title # "target =" _ blank "> </ a> <p>

<Br>
</Cfoutput>

<Cfelse>

<! --- If a parameter is passed --->
<Cfquery name = "gotoURL" datasource = "# DSN #">
Select adid, URL, CLICK FROM AD
Where adid = '# URL. ADID #'
</Cfquery>

<! --- Clicks plus 1 --->
<Cfset adclick = GOTOURL. CLICK + 1>

<Cfquery datasource = "# DSN #" name = "UPDATECLICK">
UPDATE AD
Set click = '# ADCLICK #'
Where adid = '# URL. ADID #'
</CFQUERY>

<! --- Turn to the ad link address --->
<Cfoutput query = "gotoURL">
<Script language = "JavaScript">
Self. location = '# URL #';
</SCRIPT>
</Cfoutput>
</CFIF>
GAME OVER
This advertisement was changed from ben forta's tutorial. he introduced the idea of how to create ad strips. However, the function is poor and the URL cannot be switched. I can't record the display times and clicks, so I changed it and added some features to it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.