Hey guys! I have this page with a ritating banner, everything works perfect, 
the only thing is that since I am showing 3 banners in 3 differenplaces in the 
page, the code is too long, and I hate that.

Is there a way I can place the following code in the Application.cfc and call 
it from there? so that I won't have to duplicate the code in all the pages.

Here is the code:

<!--- Start Query Banner DB --->
<cfquery datasource="advertisers" name="banner">
select *
from TopBnr_GDA3
order by ID desc
</cfquery>
<!--- End Query Banner DB --->

<!--- Start Weighting and Rand Num. --->
<!--- This starts your list for all the numbers to pick from --->
<cfset prodlist="">
<!--- Telling it to output the data queried --->
<cfoutput query="banner">
<!--- Creating a counter --->
<cfset x=1>
<!--- Starting the loop --->
<cfloop index="x" from="1" to="#banner_weight#">
<!--- This added the banner ID to the list for every weight --->
<cfset prodlist=listappend(prodlist,#id#)>
<!--- Adding one to the counter --->
<cfset x=x+1>
<!--- The end of the looping --->
</cfloop>
<!--- End of the data query --->
</cfoutput>
<!--- This startment pulls a random number from 1 to the length of the list --->
<cfset magicnumb=randrange(1,listlen(prodlist))>
<!--- This one will pull the banner ID out from the random number point --->
<cfset magicnum=listgetat(prodlist,magicnumb)>
<!--- End Weighting and Rand Num. --->


<!--- This queries the specific banner --->
<cfquery datasource="advertisers" name="views">
select *
from TopBnr_GDA3
where id = #magicnum#
</cfquery>
<!--- start Adds 1 to view --->
<cfoutput query="views">
<CFSET add = #ban_views# + 1>
<CFQUERY datasource="advertisers" name="UpdateView">
UPDATE TopBnr_GDA3 Set ban_views = #add# where ID = #id#
</cfquery>
</cfoutput>
<!--- End Adds 1 to view --->

<!--This Shows the Banner-->

<cfoutput query="views">
<A HREF="redirect.cfm?ID=#magicnum#" TARGET="_blank">
<IMG SRC="#banner_pic#" alt="#banner_alt#"></A>
</cfoutput> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3659
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to