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
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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.