Here's a bit of code that implements a lookup table.  Not sure if you
consider this to be too processor intensive.  I imagine it would do pretty
well when the initial query returns fewer than 10 or 20 records.  I
wouldn't be surprised if a SQL expert could do this purely in SQL with
just a couple of queries.

The code below doesn't require that the ad weightings ad up to exactly
100.  They might be any relative numbers - 2, 1, 1, 3 for example, or 100,
125, 350, 95.

Jim


<!--- Get all ads which meet some criteria --->
<cfquery name="ads" datasource="myDSN">
SELECT *
FROM adtabele
WHERE ...
</cfquery>

<!--- Populate an array with beginning points of ad ranges
      from 1 to total of weights --->
<cfset adranges = ArrayNew(1)>
<cfset ptr = 1>
<cfloop query="ads">
  <cfset adranges[ads.currentrow] = ptr>
  <cfset ptr = ptr + ads.weight>
</cfloop>

<!--- Generate random integer in range 1 to total of weights --->
<cfset adptr = RandRange(1, ptr - 1)>

<!--- Find array/query index of ad pointed to by random number --->
<cfloop index="adindex" from=1 to=#ads.recordcount#>
  <cfif adranges[adindex] gt adptr>
    <cfbreak>
  </cfif>
</cfloop>
<cfset adindex = adindex - 1>

...

<!--- Within the template, address the selected query record
      using adindex --->
<cfoutput>
<a href="..."><img src="#ads.graphic[adindex]#"
                   width="#ads.imgwd[adindex]"
                   height="#ads.imght[adindex]" ...></a>
</cfoutpu>





-----Original Message-----
From: Mark Warrick <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, April 12, 2000 9:22 PM
Subject: RE: HELP: banner ad weighting factors....


Yes, we've been thinking along the same lines, but so far we haven't been
able to do either of those without creating far too much processing time.

I'll tell you all what.... I'll up the ante a bit.  Whoever figures this
out AND provides sample code that solves the problem will get a copy of
the entire banner ad app.  This banner ad app should be pretty competitive
with all the others available on the dev exchange.

---mark

--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------


-----Original Message-----
From: Tom Forbes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 12, 2000 7:35 PM
To: [EMAIL PROTECTED]
Subject: Re: HELP: banner ad weighting factors....


Mark  -

How about an array or look-up table. I did this successfully with a Monte
Carlo simulation I wrote to address queing theory. Was that a dry project.
A weighted randomly generated number would designate the probability of an
event. Your columns can be probibility (30% = .3) and so on.

Tom


At 10:03 PM 4/12/00, you wrote:


>Hello All,
>
>I plan to offer banner ads on our Fusioneers.com web site ASAP.  I don't
>want to use any of the canned scripts from the developer's exchange for
>various reasons that I don't want to dwell on here.
>
>The way the banner displays are going to work is this....
>
>All Fusioneers.com partners are entitled to a free banner ad on our
>site.  People who pay a monthly fee will obviously be given a far greater
>weighting factor than the freebies.
>
>So, our plan was to do something like the following:
>
>All freebie ads combined would account for 1% of the total weighting
factor.
>
>We would then sell off weights in blocks of 10%, 20% and 30% of
>impressions until the maximum of a 100% has been reached.  The unsold
>weight blocks would display a "Your Ad Here" ad.
>
>So, in other words, when we display the ads, they will be called at
>random, but I want the weights to affect their odds of being displayed.
>
>Hopefully this makes sense.  By the way, for the person who figures out
>the best solution, we'll give you a 30% block of the 1st month's banner
ad
>weighting absolutely free as our way of saying thank you.
>
>---mark
>
>--------------------------------------------------------------
>Mark Warrick
>Phone: (714) 547-5386
>Efax.com Fax: (801) 730-7289
>Personal Email: [EMAIL PROTECTED]
>Personal URL: http://www.warrick.net
>Business Email: [EMAIL PROTECTED]
>Business URL: http://www.fusioneers.com
>ICQ: 346566
>--------------------------------------------------------------
>
>-------------------------------------------------------------------------
-----
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebarsts&bodysts/cf_talk or send
>a message to [EMAIL PROTECTED] with 'unsubscribe' in the
body.

Thomas J. Forbes
Forbes Consulting

TEL: 407-772-3427
FAX: 407-772-3428

http://www.medmatrix.com
MedMatrix Medical Equipment Portal




--------------------------------------------------------------------------
----
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

--------------------------------------------------------------------------
----
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=sts&body=sts/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to