homepage Welcome to WebmasterWorld Guest from 54.166.105.24
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Banner Rotator ?
mike2010

5+ Year Member



 
Msg#: 4684155 posted 4:21 pm on Jul 1, 2014 (gmt 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 ?

 

creeking

5+ Year Member



 
Msg#: 4684155 posted 7:36 pm on Jul 1, 2014 (gmt 0)

could you use random php includes?


the various include files could contain whatever you want

mike2010

5+ Year Member



 
Msg#: 4684155 posted 11:26 pm on Jul 1, 2014 (gmt 0)

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

mike2010

5+ Year Member



 
Msg#: 4684155 posted 1:21 am on Jul 3, 2014 (gmt 0)

think I found what I needed here.

[w3schools.invisionzone.com...]

for others, if needed ^

martinibuster

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



 
Msg#: 4684155 posted 2:05 am on Jul 3, 2014 (gmt 0)

Thanks for the link!

penders

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



 
Msg#: 4684155 posted 10:45 am on Jul 3, 2014 (gmt 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...
[].
mike2010

5+ Year Member



 
Msg#: 4684155 posted 5:00 pm on Jul 3, 2014 (gmt 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.

mike2010

5+ Year Member



 
Msg#: 4684155 posted 12:15 pm on Jul 15, 2014 (gmt 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];

penders

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



 
Msg#: 4684155 posted 1:39 pm on Jul 15, 2014 (gmt 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.)

mike2010

5+ Year Member



 
Msg#: 4684155 posted 12:43 am on Jul 16, 2014 (gmt 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.

penders

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



 
Msg#: 4684155 posted 1:32 am on Jul 16, 2014 (gmt 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. :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved