Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Lucifer

Lucifer Avatar

*******
Mythical Studio Member

Eunuch
5,665


August 2005
I have 7 images made up for randomization. Now, here's a few questions.

1. Do I have to upload the images?
2. What do I save the file to/as to upload?
3. How do I save the file?
4. Will RipWay work to upload the file?
5. Do I put the image name or URL in the code?

Answers to those would be nice, plus maybe how to do it. Plus, a code would be nice. I've seen some variations, but considering there may be another way, whoever helps me might have a different way of doing it so posting the code would be helpful. Thanks!


crazynarutard

crazynarutard Avatar

*****
Senior Studio Member

1,470


August 2005
1. Yes
2. .php
3. put the code in notepad and save it as a .php, the same way you would save a .html
4. Yes
5. depends on the code you use, but i believe the whole url :)

Boag

Boag Avatar
Yo Yo Ma!

**
Official Member

65


September 2005
Here's a quick script that will randomise between your 7 images, i'm just doing this straight off the top of my head so post back if you get any errors:

Firstly, save your images as image1, image2, image3 and so on, this helps me cut down the script a lot!

<?php

$file_type = "gif";
$folder_url = "http://www.yourhost.com/images/";

$select_image = rand(1,7);
echo "<img src=\"".$folder_url."image".$select_image.".".$file_type."\">";

?>


Edit $folder_url and $file_type to the correct values and the save that in a .php file. :)

- Boag










Last Edit: Sept 8, 2005 19:36:21 GMT by Boag

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
there is also another way... bit longer script thou.... using arrays... and its not as effective as boag's but it allows you to have links with them


<?

$images = array(
  'image1.gif',
  'image2.gif',
  'image3.gif',
);

$links = array(
  'link1',
  'link2',
  'link3',
);

$rand_img = array_rand($images, 2);

foreach ($rand_img as $key) {
  echo '<a href="http://'.$links[$key].'" target="_blank"><img src="'.$images[$key].'" alt="" border="0"></a>'
}
?>

again this one is off the top of my head.. so any errors... let me know


Last Edit: Oct 30, 2005 11:08:25 GMT by Llanilek

newBookmarkLockedFalling