Welcome to WebmasterWorld Guest from 50.16.84.67

Forum Moderators: coopster & jatar k

PHP Banner Rotator ?

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

5+ Year Member



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 Jul 1, 2014 (gmt 0)

5+ Year Member



could you use random php includes?


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

5+ Year Member



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

5+ Year Member



think I found what I needed here.

[w3schools.invisionzone.com...]

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

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



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

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



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 Jul 3, 2014 (gmt 0)

5+ Year Member



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 Jul 15, 2014 (gmt 0)

5+ Year Member



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 Jul 15, 2014 (gmt 0)

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



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 Jul 16, 2014 (gmt 0)

5+ Year Member



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 Jul 16, 2014 (gmt 0)

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



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. :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month