|
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!
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|