Need Help Rotating Banners.

by 3 replies
4
Hi on the prosper202 website they give the following script to rotate landing pages. I want to rotate banner ads on a site and I thought I could just change the different landing page urls to different image or flash urls, but when I do it does not work.

Is there a way to change the script to work for returning different banner ads instead of landing pages?

I want to buy ad space on a different website and then be able to rotate ads without asking them to keep changing the image source and destination url.

Thanks

PHP Code:
 <?

//Tracking202 Landing Page Rotation Script

//landing pages filenames, theses will be rotated between eachother
//theses landing pages must be in the same DIRECTORY as this file
//you can add as many landing pages here as you like
$landingpage[1] = 'landingpage1.php';
$landingpage[2] = 'landingpage2.php';
$landingpage[3] = 'landingpage3.php';

//this is the text file, which will be stored in the same directory as this file, 
//count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
$myFile = "count.txt";

//open the txt file
$fh = @fopen($myFile, 'r');
$lpNumber = @fread($fh, 5);
@fclose($fh);

//see which landing page is next in line to be shown.
if ($lpNumber >= count($landingpage)) {
    $lpNumber = 1;
} else {
    $lpNumber = $lpNumber + 1;
}

//write to the txt file.
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $lpNumber . "\n";
fwrite($fh, $stringData);
fclose($fh);

//include the landing page
include_once($landingpage[$lpNumber]); 

//terminate script
die();

?>
#programming #banners #rotating
  • Prosper202 isn't for serving ads, it's for tracking PPC campaigns.

    To do what you want, you'll probably need to use the OpenX ad server. OpenX. Build your business here. | OpenX
  • Using PHP's rand() (random number generator) function is the quickest way to write an ad rotator script - I often use this trick for page headers as well.

    Some easy sample code to get you started:

    Rotate Ads with PHP Mark Sanborn . net

    Random Images with PHP | Devlounge

    Bill
    • [ 1 ] Thanks
    • [1] reply
    • Those rotators work well, and it is pretty easy to write one. Our original poster, though, has to serve ads to another web site - and while OpenX is way overkill, it's the easiest way (relatively speaking, of course) to supply rotating ads to another site.

Next Topics on Trending Feed

  • 4

    Hi on the prosper202 website they give the following script to rotate landing pages. I want to rotate banner ads on a site and I thought I could just change the different landing page urls to different image or flash urls, but when I do it does not work. Is there a way to change the script to work for returning different banner ads instead of landing pages?