This is supposed to randomly generate a number which will then select an ad image, its link, and text to display. I cant get it to work. Any suggestions?
PHP Code:<?php
//---- Ad rotator
?>
<p><a href="http://<?php print $link; ?>"><img src="<?php print $ad; ?>" alt="<?php print $alt; ?>" width="150" height="230" border="0"> </a> </p>
<?php
//random number generator
$ad_number = rand(1,2);
//assign link & ad based in random number
if ($ad_number == "1")
{
$link = "www.awebsite.com";
$ad = "/ads/ja-curren-ad.gif";
$alt = "Ad Number One";
}
elseif ($ad_number == "2")
{
$link = "www.website.com";
$ad = "/ads/place-ad.gif";
$alt = "Ad Number Two";
}
else
{
$link = "www.another-website.com";
$ad = "/ads/place-ad.gif";
$alt = "Place an ad!";
}
//---- END OF RANDOM AD GENERATOR
?>


Reply With Quote
Bookmarks