Jump to content
xisto Community
Sign in to follow this  
ChronicLoser

Random Banners Rotation... set by percentages

Recommended Posts

alright, I know a few different ways to make a random banner with php - where a different banner would rotate with every refresh/click. But I've had some "customers" complain how they think their banner should show up more then others for one reason or another, and I completely agree with them. So now I kinda want to have a code (most perferably php or javascript) that would have the banner rotation where I could set a peticular banner to show up say 15% of the time and another 5% so I could satisfy my more loyal members over the ones simply looking for more hits to their site. Can someone give me a way of doing this?And I don't want to do something like this:banner1.gifbanner1.gifbanner1.gifbanner1.gifbanner2.gifbanner2.gifbanner2.gifbanner2.gifbanner2.gifbanner3.gifbanner3.gifbanner4.gifbanner5.gifbanner6.figbecause I'm a too lazy to make those kind of calculations everytime someone joins my banner rotation system. Alright then. THanks in advance for anyone willing to help me out here

Share this post


Link to post
Share on other sites

Problem wuth that kind of system is that... If you promise one of your advertisers say 15% of the time. That meaning that of 100 page loads their ad should be displayed 15 times.
But what happens when you add new advertisers to your system? You only have 100% of page loads and if you add more advertisers the percentage of other's ads has to drop.


Anyways, let's say that you have set number of advertisers. What you can simply do is save table like this:

ad1 -> 15
ad2 -> 30
ad3 -> 50
ad4 -> 100

There ad1 and ad2 would have 15% chanhe of being vieved, ad3 20% and ad4 50% change.

Than just create random numbers ranging from 1 to 100 and loop through your table like this:

$rand = rand(1, 100);foreach ( $ads as $ad_number => $limit ){	if ( $rand <= $limit )	{ 	 $ad_to_view = $ad_number; 	 break;	}}

Share this post


Link to post
Share on other sites

I would recommend a adserving system based on php and mysql to you. It's called phpAdsNew, a free open-source system. You can download it at http://forums.xisto.com/no_longer_exists/. In fact i think you have this script in in your cpanel's scripts section.

Once you installed it, you basically can run an adserver like Valueclick or the other major ad firms, except perhaps phpadsnew is less "pro". Anyway, you can set priority to different banners. Say if you want banner A to appear more than banner B, then you can give a heavier weiht to banner A, and the adserver will make the calculation and serve your ads the way you want it.

hope this helps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.