Welcome to WebmasterWorld Guest from 54.234.38.8

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Banner Rotator ?

     
4:21 pm on Jul 1, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


Looking for a dynamic banner rotator script that can rotate Flash / Php / Banners along with regular static image ones. (GIF / JPG)

preferably a locally hostable one. and something popular / mainstream ?
7:36 pm on July 1, 2014 (gmt 0)

Preferred Member

5+ Year Member

joined:June 15, 2007
posts:408
votes: 9


could you use random php includes?


the various include files could contain whatever you want
11:26 pm on July 1, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


yea, but i'd like to display like 3 different banners equally. (impression wise)
1:21 am on July 3, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


think I found what I needed here.

[w3schools.invisionzone.com...]

for others, if needed ^
2:05 am on July 3, 2014 (gmt 0)

Moderator from US 

WebmasterWorld Administrator martinibuster is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 13, 2002
posts:13964
votes: 119


Thanks for the link!
10:45 am on July 3, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


creeking: could you use random php includes?


mike2010: ...but i'd like to display like 3 different banners equally. (impression wise)


The linked script displays a pseudo-random response on every request. Is that equal enough?

Minor update to the linked script:
$iframe[] = '<iframe ...'; 
$iframe[] = '<iframe ...';
$iframe[] = '<iframe ...';


There is no need to specify the array index 0, 1, 2, etc. when you are simply appending to the array. PHP essentially does that for you, by simply using two empty square brackets...
[]
.
5:00 pm on July 3, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


Thanks for the link!


I'm really glad as well...in years past, i'd have to download some banner script, with a million files...just to get it all together. (especially for dynamic banners) now just some php coding all on 1 page....is all that's needed. :)

Penders, thanks.. I'll try that out tonight.
12:15 pm on July 15, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


Minor update to the linked script:

$iframe[] = '<iframe ...';
$iframe[] = '<iframe ...';
$iframe[] = '<iframe ...';



There is no need to specify the array index 0, 1, 2, etc. when you are simply appending to the array. PHP essentially does that for you, by simply using two empty square brackets... [].


penders, I was going to try that now.

what about the variables after that, any change needed or no?

$numbers = range(0, 2);
shuffle($numbers);
foreach ($numbers as $number):
endforeach;
echo $iframe[$number];
1:39 pm on July 15, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


Well, errm... what have you done there?! And why? (Apart from the unnecessary, your code limits the number of banners to 3 - so you would need to change this if you added more.)

(The reason for the change I suggested above is simply that it's easier to maintain (and one less character to type). It is otherwise identical to the original code.)

What was wrong with the original code...?
shuffle($iframe); 
echo $iframe[0];


shuffle() randomizes the order of the $iframe array. Then $iframe[0] returns the first element. Since the array has been shuffled (like a deck of cards), the first element is different every time. (shuffle() isn't particularly great for randomness, but it is OK for something like this.)
12:43 am on July 16, 2014 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
posts:495
votes: 0


ahh, nevermind. hehe I went with his 2nd code near the bottom of that thread. I'll just use the top one.

very effective banner exchange code. I'm using 3 300 x 250 ads, all aligned near the top... with 8 different banners for each banner instance.

I put all of those in 1 file. and then call it clean with another iframe. (so all those iframe banners are in an off-site file)

easy to use the same banner exchange URL for multiple sites.
1:32 am on July 16, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


hehe I went with his 2nd code near the bottom of that thread. I'll just use the top one.


Ah, I didn't see the 2nd version down there! Yes, use the top one. :) (That 2nd version is just bizarre and a bad code smell - yes, it should work, but in the most roundabout way possible!)

Glad you got it working OK. :)