Forum Moderators: coopster

Message Too Old, No Replies

ASP AdRotator equivalent

         

defanjos

2:48 pm on Oct 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a equivalent in PHP for the ASP AdRotator?

Basically I want to be able to show 3 different includes at specific time percentages. For example, each of the 3 includes 33.33% of the time each.

I am new at PHP.
I looked online, but am only able to find random rotators.

Thanks for the help.

jatar_k

3:17 pm on Oct 25, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



have you looked at phpadsnew? I think it has a weighting system like that, not sure though

hughie

8:04 pm on Oct 25, 2006 (gmt 0)

10+ Year Member



a simple rand() would do it at it's most basic level

<?php

$theVal=rand(0,2);

switch($theVal)
{
case 1:
include("include2.php");
break;

case 2:
include("include3.php");
break;

default:
include("include1.php");
break;
}

?>

to make sure it's fair you could record each selection to a database, then only call those that haven't already been shown.

barns101

9:35 pm on Oct 25, 2006 (gmt 0)

10+ Year Member



I used phpAdMentor, which allows you to set ad zones, weight ads and gives loads of reporting options.

defanjos

11:38 pm on Oct 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks or the tips

eelixduppy

11:42 pm on Oct 25, 2006 (gmt 0)



>>but am only able to find random rotators.
>>for example, each of the 3 includes 33.33% of the time each.

This is contradictory ;) If you want 3 includes to be included 33.3% of the time, then each of them have the same probability of being chosen, therefore it's simply a random generator.

Following up on some of the previous examples, you can also use shuffle:


$files = [url=http://us3.php.net/manual/en/ref.array.php]array[/url]("file1.html","file2.html","file3.html");
[url=http://us3.php.net/manual/en/function.shuffle.php]shuffle[/url]($files);
include($files[0]);

Best of luck! :)

defanjos

2:33 am on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I could be wrong, but if it is random, there is a chance (in a given day), for example, that one will be 25% the other 35% and the third one 40%

Over time, I guess it will even out to 33.33% each.

eelixduppy

2:38 am on Oct 26, 2006 (gmt 0)




I could be wrong, but if it is random, there is a chance (in a given day), for example, that one will be 25% the other 35% and the third one 40%

That is if you are keeping track of how many show up of each throughout the day. The probabilty is truly 33.3% each time the page loads that any one will be selected.

If you are worried about users seeing the same content more than once before they view the others, there is a 33.3% chance that this will happen, but a more probable 66.6% chance that they will see something different.


Over time, I guess it will even out to 33.33% each.

Yes, it should eventually approach 33.33%...in theory ;)

defanjos

2:43 pm on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks eelixduppy, I'll be using your simple solution. I like the 3 lines of code.