9, January 2009

banner rotation - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: banner rotation
« previous next »
Pages: [1] Print

Author Topic: banner rotation  (Read 831 times)
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« on: Mar 11, 2006, 08:56:04 PM »

I'm working on a banner rotation script for my new site but I'm not sure what would be the best way to rotate the banners in the pool. All the banners are stored in a database, I was thinking about adding an extra field to mark the last displayed banner (or the next one to be displayed) But since the users of the site can submit/delete their own banners this could cause a problem (when the marked record is deleted)
How would you implement the rotation of a banner pool?


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8362
43159 credits
Members referred : 3



« Reply #1 on: Mar 11, 2006, 09:34:34 PM »

Do you want to equally display the banners?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #2 on: Mar 11, 2006, 10:12:36 PM »

for starters, yes


Last blog : Are You Stumbling Yet?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #3 on: Mar 12, 2006, 12:12:41 AM »

Looks like I've nailed it: I'm counting the number of records in the banner pool and create a random number between 1 and the number of banners, thats the banner number that will be displayed...
Do you think this is a good way of doing this?


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8362
43159 credits
Members referred : 3



« Reply #4 on: Mar 12, 2006, 01:43:43 PM »

You could do this by using ORDER BY RAND(), but it still wont give the same impressions to every banner.

The best way is to add a field which will keep the count of impressions (eg. impr) and do something like :

SELECT id, .. .... . . .. .. . . . . . FROM banners ORDER BY impr ASC LIMIT 1

And then after you show the banner execute something like :

UPDATE LOW_PRIOTITY banners SET impr = impr + 1 WHERE id = $id LIMIT 1

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
OMG!I am geek
**
Gender: Male
Posts: 56
374 credits
Members referred : 0



« Reply #5 on: Mar 12, 2006, 02:00:30 PM »

You could do this by using ORDER BY RAND(), but it still wont give the same impressions to every banner.

The best way is to add a field which will keep the count of impressions (eg. impr) and do something like :

SELECT id, .. .... . . .. .. . . . . . FROM banners ORDER BY impr ASC LIMIT 1

And then after you show the banner execute something like :

UPDATE LOW_PRIOTITY banners SET impr = impr + 1 WHERE id = $id LIMIT 1

Interesting. I will do that too.

Thanks Smiley
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #6 on: Mar 12, 2006, 03:12:33 PM »

I'll try that, I already keeping a 'views counter' on the banners and I did notice that the random function does not show the different banners the same number of times, although it should in the long run...
A problem with your sollution would be that if the banners have been shown a lot of times already, a newly added banner will be shown exclusively untill its count is up to the same number, but I guess this can be solved by setting the counter to the same value as the other banners when adding a new banner.


Last blog : Are You Stumbling Yet?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8362
43159 credits
Members referred : 3



« Reply #7 on: Mar 12, 2006, 03:26:52 PM »

Yes because otherwise the solution would be very costly to your server's CPU usage.

Except if you also use a php array on the session to know what banners you have shown to the user (so you want serve the same banner twice)

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Monetizing Old Posts
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1761
Tags : php databases Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: banner rotation
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jan 09, 2009, 11:43:00 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 38.666
Total Topics: 7.773
Total Members: 4.662
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: webhostingcento

30 Guests, 5 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2009 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.