Jump to content

random synchronization of banner ads


poMONKey

Recommended Posts

I have a script that loads a new banner when the page is refreshed:

<?php 
$ban1 = "/Banners/apiana_leaderboard_728x90.jpg";
$url1 = "# target=_blank"; 
$ban2 = "/Banners/herios_leaderboard_728x90.jpg";
$url2 = "# target=_blank"; 
$ban3 = "/Banners/Links%20of%20London.GIF";
$url3 = "# target=_blank";
$ban4 = "/Banners/1473RCHorbanner.jpg";
$url4 = "# target=_blank";

$randomNum = rand (1,4);

$image = ${'ban'.$randomNum};

$url= ${'url'.$randomNum};
Print "<a href=".$url." mce_href=".$url."><img src=".$image." border=0></a>";
?>

 

This code is in an included php header and I have the same code out in the separate pages throughout the site to shuffle the banners. Everything is working just fine until the client wants to synchronize the header banners with the page banners. Thats where I hit a wall as far as coding php  goes... how do I make the header talk to the pages and load the same company's banner in both places???

 

TIA

 

p0

 

 

Link to comment
https://forums.phpfreaks.com/topic/46602-random-synchronization-of-banner-ads/
Share on other sites

You could try using a session...

 

For Example you could set the banner id in a session

 

then each time a banner is loaded you could check too see if a session is set, if it is it will load the banner in the session if not run the random banner script.

 

 

hope it helps

 

Stuie

 

if you want to show the same companys banner in two places on the page just use 2 variables..

 

<?php

$ban1 = "/Banners/apiana_leaderboard_728x90.jpg";

$secondban1 = "banner..";

$url1 = "# target=_blank";

 

$randomNum = rand (1,4);

 

$image = ${'ban'.$randomNum};

$image2 = ${'scondban'.$randomNum};

$url= ${'url'.$randomNum};

 

Print "<a href=".$url." mce_href=".$url."><img src=".$image." border=0></a>";

?>

 

now just echo $image2 further don the page..

Thanks for the responses... I almost have it and mostly understand - but Im no echoing the banner image correctly.

 

Heres how Ive been coding it:

 

<?php 
echo "${secondban1}";
?>

 

all that does is print out the URL for the banner, it doesnt actually display it...  halp!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.