Reply
 
Thread Tools
Old 26-05-2002, 12:35 AM   #1   [permalink]
gscfan
Junior Member
 
gscfan's Avatar
 
Join Date: 25 Mar 2002
Location: Richton PK IL
Posts: 35
Send a message via Yahoo to gscfan
Random Banners

Does anyone know any good scripts for making a banner ad different every time the site reloads? Thanks
gscfan is offline   Reply With Quote
Old 11-06-2002, 01:12 PM   #2   [permalink]
nade
Junior Member
 
nade's Avatar
 
Join Date: 5 Jan 2002
Posts: 25
Send a message via ICQ to nade Send a message via AIM to nade Send a message via Yahoo to nade
Do you mean a random image, or a random image and link?

For a random image, you can try this simple php script

PHP Code:
<?php

$path 
"nade/";

function 
GetDir($sPath, &$avatars
{
   
$handle=opendir($sPath); 

   while (
$file readdir($handle)) 
   {
    if (
$file != "." && $file != ".."
    {
        
$avatars[count($avatars)] = $file
    }
   }
   
closedir($handle); 
}

   
$avatars = array();

   
GetDir($path, &$avatars);

   
$i 0

   while(
$avatars[$i] != "")
   {
    
$i++;
   }
   
$i rand(0$i-1);

   include(
"".$path."".$avatars[$i]."");
?>
replace nade/ in $path, with the folder your images are in. then just call the php script.
nade is offline   Reply With Quote
Old 13-06-2002, 06:16 PM   #3   [permalink]
suzaku
Forum Master
 
suzaku's Avatar
 
Join Date: 25 Feb 2001
Location: Cephiro
Posts: 3,255
Send a message via ICQ to suzaku Send a message via AIM to suzaku Send a message via Yahoo to suzaku
if your server can't read php then you could always use a javascript

you could find one at:

Javafile
Dynamic Drive
__________________
When in doubt with thoughts, one must drink a cup of sake
suzaku is offline   Reply With Quote
Old 14-06-2002, 01:41 AM   #4   [permalink]
Keiichi
Executive Member
 
Keiichi's Avatar
 
Join Date: 19 Jul 2000
Location: At home...
Posts: 402
I would probably use javascript for this (hopefully most of your visitors ha