Forum Moderators: coopster
$content = array("page1.html","page2.html","page3.html");
[url=http://us2.php.net/manual/en/function.shuffle.php]shuffle[/url]($content);
echo [url=http://us2.php.net/manual/en/function.file-get-contents.php]file_get_contents[/url]($content[0]);
Hope this helps. Good luck!
We try and encourage you to write your own code, which is far better from a learning curve. Post what you have and we will try and help.
dc
ad_rotation.php or should I name it ad_rotation.html?
$bannerCounter= 1;
$bannerCode[$bannerCounter] = "<a href=\"http://example.com/categories.php?PARTNER=unstabletable\"><img src=\"http://unstabletable.example.net/affiliate/ad05.jpg\" border=\"0\"></a>";
$bannerCounter++;
$bannerCode[$bannerCounter] = "<a href=\"http://www.example.com/redir.php?aff=8073\"><img src=\"http://unstabletable.example.net/affiliate/hp_ad.gif\" border=\"0\"></a>";
$bannerCounter++;
$bannerAdTotals = $bannerCounter - 1;
if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];
Place where I want that code placed:
<?
include("ad_rotation.php");
echo "<div align='center'>$bannerAd</div>";
?>
$content = array(
"<a href=\"http://example.com/categories.php?PARTNER=unstabletable\"><img src=\"http://unstabletable.example.net/affiliate/ad05.jpg\" border=\"0\"></a>",
"<a href=\"http://www.example.com/redir.php?aff=8073\"><img src=\"http://unstabletable.example.net/affiliate/hp_ad.gif\" border=\"0\"></a>"
);
shuffle($content);
echo $content[0];
Best of luck!
P.S. ad_rotation.php is what you want ;)
[edited by: eelixduppy at 1:10 am (utc) on June 28, 2006]
This is the code I use to place my banners:
<?
include("ad_rotator.php");
echo "<div align='center'>$bannerAd</div>";
?>
This is the code I use on ad_rotator.php
$bannerCounter= 1;
$bannerCode[$bannerCounter] = "<a href=\"http://www.example.com/advertise.php\"><img src=\"images/youradherebig.gif\" border=\"0\"></a>";
$bannerCounter++;
$bannerCode[$bannerCounter] = "<a href=\"http://www.example.com/advertise.php\"><img src=\"images/youradhere.gif\" border=\"0\"></a>";
$bannerCounter++;
$bannerAdTotals = $bannerCounter - 1;
if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];
Why isn't it working? I can't figure it out. I am not using a database or anything, what am I doing wrong? Please help.
[edited by: coopster at 12:58 pm (utc) on June 28, 2006]
[edit reason] generalized domain [/edit]
$content = array(
"<a href=\"http://www.example.com\"><img src=\"youradherebig.gif\" border=\"0\"></a>",
"<a href=\"http://www.example.com\"><img src=\"youradhere.gif\" border=\"0\"></a>"
);
shuffle($content);
echo $content[0];
But it still won't work. Do you see any mistakes?
[edited by: coopster at 12:58 pm (utc) on June 28, 2006]
[edit reason] generalized domain [/edit]