...

View Full Version : Banner weighting ?



firepages
05-15-2008, 03:14 AM
It seems as though I should have by now ;) but I have never made an ad/banner rotator~
My main question is how would I apply a banner weighting system ... what would be the logic for that?

e.g. I want ads marked as `class 1` to show far more often than those in `class 2,3` etc but still keep some random element.

All ad data is kept in a db which I can change since I am in the early stages of development, any pointers appreciated.

peteyb383
05-15-2008, 03:24 AM
Using PHP, select a random number from 0-5

Then use Case/If statements to tell what to do depending on the random number value.

To "weigh" an ad, simply show it whenever the number is 0, 1, 2, or 3 and the 2nd ad will show on 4 and the 3rd ad on 5

Fou-Lu
05-15-2008, 04:37 AM
Sup firepages, been awhile since I've run into you on here :)
Being the king of over-complication myself, I'd write a priority queue if I were in a language like C#, and apply an algorithm that essentially allots an additional 10-15% probability for each level of the numeric queue. I guess the same logic can be applied to php as well, I'd simply keep the priority value within the database, say 1 through 5 (if we are looking at the 10-15% increase), and write a simple algorithm to drill down the priority numbers and select from that. Then randomly choose from the remaining results.

Does that make sense at all, or did I just confuse you as much as I just confused myself :P

Inigoesdr
05-16-2008, 12:08 AM
All ad data is kept in a db which I can change since I am in the early stages of development, any pointers appreciated.

If it's MySQL(and not a huge table, as RAND() can be kinda slow) you can use
SELECT * FROM `table` WHERE 1 ORDER BY RAND() * `weight``weight` would be a pre-determined value that you have set individually in each column or hard-coded in your script.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum