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 have Javascript enabled browsers). With JS, you can also make it rotate randomly every certain amount of time without reloading the page.
__________________
K1
"Belldandy's drunk? But why now?!...No way...because of COLA?" :goof:
Keiichi is offline   Reply With Quote
Old 17-06-2002, 08:40 PM   #5   [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
hai hai

JS is the most flexible language ^^
__________________
When in doubt with thoughts, one must drink a cup of sake
suzaku is offline   Reply With Quote
Old 03-09-2004, 08:07 AM   #6   [permalink]
rei123456789
Junior Member
 
rei123456789's Avatar
 
Join Date: 5 Mar 2002
Location: In between Rei Ayanami's Breast
Posts: 37
Send a message via ICQ to rei123456789 Send a message via AIM to rei123456789 Send a message via Yahoo to rei123456789
i wrote a very simple script similar to nades for this. All you need to do is name the images with a number. Have the script creating a random number, then store the number in a variable. This will then show the image by using img src="$var.jpg". You can do it in less than 10 lines of code or so. Very simple php script, and much more reliable than java ^_^
__________________
I love Rei Ayanami, she is the best. I will argue with anyone who says otherwise.
rei123456789 is offline   Reply With Quote
Old 13-08-2008, 06:13 AM   #7   [permalink]
clint999
Banned
 
Join Date: 19 Jul 2008
Posts: 10
I would probably use javascript for this (hopefully most of your visitors have Javascript enabled browsers). With JS, you can also make it rotate randomly every certain amount of time without reloading the page.
clint999 is offline   Reply With Quote
Old 19-07-2009, 12:46 AM   #8   [permalink]
zenpher
Junior Member
 
Join Date: 19 Jul 2009
Posts: 2
Here use this:

http://javascript.internet.com/misce...dom-image.html

It's fairly self explanatory.
zenpher is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


New To Site? Need Help?

All times are GMT -4. The time now is 08:31 AM.


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2018, vBulletin Solutions, Inc.