Author |
Message |
Corybu
|
Posted: Sat Oct 04, 2003 4:57 pm Post subject: Random images? |
|
|
Anyone know how to display random images?
Ive got a website that I need to make for a friends band, and I have various logos that i'd like to place in a frame in the top left corner.
If anyone could tell me how this os done, or point me to t autorial for it, or give me a code/script for it, Id be very grateful.
Thanking you all in advance,
Cory. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Blade
|
Posted: Sat Oct 04, 2003 5:09 pm Post subject: (No subject) |
|
|
well... you'd have to use some sort of scripting language... ie: perl, php etc. |
|
|
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:10 pm Post subject: (No subject) |
|
|
I dont know either of those....
Could you or someone here help me out with this one?
I was hoping there was an html way... |
|
|
|
|
|
Blade
|
Posted: Sat Oct 04, 2003 5:14 pm Post subject: (No subject) |
|
|
no... html is pretty much tags that format text, it cant caculate anything
well... i'd read the images from a folder into an array, then use a random integer in the array element from 1 to the amount of pictures in the array, then use html to present it... |
|
|
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:15 pm Post subject: (No subject) |
|
|
Lol... I dont get it. Do all that stuff with html? or another script?
Ive never done any scripting... |
|
|
|
|
|
Amailer
|
|
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:26 pm Post subject: (No subject) |
|
|
So, with that, I just put it on the html page where I want it to appear, and put the pics in a directory all by themselves? |
|
|
|
|
|
Amailer
|
Posted: Sat Oct 04, 2003 5:27 pm Post subject: (No subject) |
|
|
Which one you are talking about? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:27 pm Post subject: (No subject) |
|
|
the php script |
|
|
|
|
|
Amailer
|
Posted: Sat Oct 04, 2003 5:30 pm Post subject: (No subject) |
|
|
1: you need php installed,
create a .php file (i.e: randomeimg.php )
put the script in, and add afer that
code: |
$dir="./where the/images/are/";
getRandomImage($dir);
|
|
|
|
|
|
|
Blade
|
Posted: Sat Oct 04, 2003 5:31 pm Post subject: (No subject) |
|
|
code: | <?
$dir = "images/";
$i = 0;
if ($handle = opendir($dir)) {
while (false !==($file[$i] = readdir($handle))){
$i++;
}
}
$img = $dir . $file[rand(2,$i - 1)];
echo "<img src=$img>";
?> |
what amailer gave you as a function... this is the most simple way you can do it...
its php... you need a server that supports php to use it, and you also need ot name your file .php instead of .htm/.html ... or else the server wont execute it..
you can see it working at http://dblade.sytes.net/new/readdir.php
what it does is it reads the folder /images (which is in my new folder on the server) that is full of images, into an array.. then it gets a random number between 2 (because the first two it reads is . and .. ) and the maximum number of images in the folder, then you use the random number in the array to call a random array element
ie: $arrayname[randomnumber] |
|
|
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:31 pm Post subject: (No subject) |
|
|
Im assuming I need some kind of software installed to run PHP then?
This site isnt getting hosted on a private server... its just going on free webhosting... Ill have to see if it can use php... |
|
|
|
|
|
Blade
|
Posted: Sat Oct 04, 2003 5:33 pm Post subject: (No subject) |
|
|
umm... the server you're using needs to have php for you to use php...
theres only a couple free server that i know of that have php...
tripod.co.uk and host.sk (which isnt in english) |
|
|
|
|
|
Corybu
|
Posted: Sat Oct 04, 2003 5:35 pm Post subject: (No subject) |
|
|
I see... Well, as long as its free, I can probably have the site hosted there... Ill just get redirect service for it.
Thanks for the help guys. |
|
|
|
|
|
Amailer
|
Posted: Sat Oct 04, 2003 5:36 pm Post subject: (No subject) |
|
|
better if you use the JAVASCRIPT ONE, cuz you don't have PHP |
|
|
|
|
|
|