How do I do do the random banner change as I'm needing it for my upcoming sites advert system
PHP Code:<?php
srand( microtime() * 1000000);
$advertise = rand(1,3);
switch($advertise)
{
case 1 : $banner="URL"; $url="Link"; break;
case 2 : $banner="URL"; $url="Link "; break;
case 3 : $banner="URL"; $url="Link"; break;
}
$display = "<a href=\"$url\"> ";
$display.= "<img src=\"$banner\" ";
$display.= "width=\"495\" height=\"80\" border=\"0\" >";
$display.="</a>";
echo($display);
?>
Last edited by Encryptions!; 14-03-2006 at 08:32 PM.
I'll code you a JavaScript one, as then you don't need a host which supports PHP:
Code:<script type="text/JavaScript"> <!--Begin // Addresses of images var image_addresses = new Array('cat.gif','dog.gif'); // Generate a random number var rand_num = Math.floor(Math.random()*image_addresses.length); function display_banner() { var build_image; // !! Build image build_tmp=document.createElement('img'); build_tmp.src=image_addresses[rand_num]; document.body.appendChild(build_tmp); // !! Image appended to body } display_banner(); //--> </script>
kinda quit.
Very nice Encryptions and Nets -Thumbs up- i could never create one my self
Never argue with an idiot, he'll drag you down to his level, and beat you with experience.
And 15 mins later...Originally Posted by Recursion
*oh trust me
*I would NEVER go ATi
Sapphire ATI Radeon HD 5850 1024MB GDDR5 PCI-Express Graphics Card £195.73 1 £195.73
*ordered.
Most Paid For Hosts Have PHP Support - otherwise people woudn't buy them.. but if its a free host, eg Piczo etc then it deffintly won'tOriginally Posted by Respect
Thanks guys I think i'll go with Nets as i'm not sure if my host has PHP enabled
Want to hide these adverts? Register an account for free!