Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Generating Random Records based on weight
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Generating Random Records based on weight

 Post Reply Post Reply
Author
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Topic: Generating Random Records based on weight
    Posted: 25 May 2003 at 8:06pm
I have a script that displays a random record. (basically selects an ad banner from a database) but i'm trying to figure out how to make a record with a weight of 2 display twice as much as a banner with a weight of two. For example if I have 2 banners one with a weight with 1 and the other with a weight of 2 and the script is run 1000 times i want banner 1 to be displayed approximately 333 times and banner 2 to be displayed 666 times. Does anyone have any ideas?
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 25 May 2003 at 9:50pm

You can easily use the builtin ad rotator that comes with IIS. Just create a text file like:
REDIRECT /anyfile.asp
WIDTH 468
HEIGHT 60
BORDER 1
*
http://www.YOUR_DOMAIN_NAME.com/images/banner1.gif
http://www.ADVERTISER1_DOMAIN_NAME.com
Visit Advertiser1 now!
25
http://www.YOUR_DOMAIN_NAME.com/images/banner2.gif
http://www.ADVERTISER2_DOMAIN_NAME.com
Visit Advertiser2 now!
25
http://www.YOUR_DOMAIN_NAME.com/images/banner3.gif
http://www.ADVERTISER3_DOMAIN_NAME.com
Visit Advertiser3 now!
40
http://www.YOUR_DOMAIN_NAME.com/images/banner4.gif
http://www.ADVERTISER4_DOMAIN_NAME.com
Visit Advertiser4 now!
10

where the numbers are the percentages.

Then a simple script to call them:
<%
DIM strBanners
Set strBanners = Server.CreateObject("MSWC.AdRotator")
Response.Write (strBanners.GetAdvertisement("/adrotator.txt"))
%>

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2003 at 10:42am

i think you misunderstood me... what if i want one of those banners to appear twice as much as another.  I already have a management program that counts clicks, shows, etc. but i would like to modify the following lines in the banner selection script

    RANDOMIZE
 Randomno = int((mytable.recordcount * rnd) + 1)
 mytable.absoluteposition = cint(randomno) ' go to the record

so that a record containing a "weight" on 2 will be twice as likely to appear than a banner with a "weight" with 1

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 26 May 2003 at 5:10pm

I did not misunderstand you; I was just saying that e.g. below, the first one would show abou twice as much as the second one. I don't know how your code looks like right now and your db to tell you how to implement it to your existing script.

http://www.YOUR_DOMAIN_NAME.com/images/banner3.gif
http://www.ADVERTISER3_DOMAIN_NAME.com
Visit Advertiser3 now!
63
http://www.YOUR_DOMAIN_NAME.com/images/banner4.gif
http://www.ADVERTISER4_DOMAIN_NAME.com
Visit Advertiser4 now!
37



Edited by michael
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2003 at 6:04am
Or, if you don't want to use IIS's inbuilt rotator, you could simply duplicate the double-weighted banner entry.

ie., you'd have three entries - one for banner 1, and two for banner 2. On a random 1,000 views, banner 1 would get seen around 333 times, as would each of the instances of banner 2. Being identical, banner 2 would therefore get seen roughly 667 times.

Bit of a bodge though, when IIS will do it for you!
www.pedalcars.info

The most fun on four wheels

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2003 at 1:03pm
excellent idea... that pretty much what i need. Banner 2 will be twice as likely to be shown as banner one. Good Idea!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.