View Full Version : PHP : Help
YouFail
14-03-2006, 08:27 PM
How do I do do the random banner change as I'm needing it for my upcoming sites advert system
Encryptions!
14-03-2006, 08:31 PM
<?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);
?>
I'll code you a JavaScript one, as then you don't need a host which supports PHP:
<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>
Flisker
15-03-2006, 05:48 AM
Very nice Encryptions and Nets -Thumbs up- i could never create one my self
YouFail
15-03-2006, 07:27 AM
Thanks guys I think i'll go with Nets as i'm not sure if my host has PHP enabled
Lycan
15-03-2006, 07:49 AM
Thanks guys I think i'll go with Nets as i'm not sure if my host has PHP enabled 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't
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.