Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotating Ads
21-07-2011, 04:11 PM (This post was last modified: 21-07-2011 04:13 PM by Punktured.)
Post: #1
Information Rotating Ads
Since everyone wants rotating banners, here is a simple way to get them...

how to install:

1. create a file in your root folder called rotatingads.txt
2. place this code, either in your Free HTML Area or your themes template (if you know how) where you wish your banner to display...

code:
Code:
<?php
$filename = 'http://www.domain.com/rotatingads.txt';
$how_many_to_show = 1;
if ($fileContents = file($filename)) {
shuffle($fileContents);
for ($i = 0; $i < $how_many_to_show; $i++) {
   $myvariable = ($fileContents[$i]);
}
} else {
die('Could not get contents of: ' . $filename);
}  
echo $myvariable;
?>

note:
in the code i have provided, you will have to put your url, where it says http://www.domain.com/rotatingads.txt

rotatingads.txt explained:
this is important, so make sure you understand...
each ad code, must be on one line each...
ad code 1
ad code 2
ad code 3

added bonus:
depending where you want your ads to display, and what size your ads are...
there is an included variable in the code "$how_many_to_show"...
this will be the number of ads your script shows at any one time...
so, if your using this code in your sidebar and wish to show two random ads, one under the other...
set it to 2 and make sure you have a < br > (with no spaces) at the end of each ad code line...

simple as that...

Custom HTML/CSS/PHP
http://theorderofindividualacceptance.co...p.php?id=1
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: