...

View Full Version : Randomly choosing an image



Psychoman
04-18-2004, 04:59 AM
i have a web site that has 3 logos, Say A B and C, each one is cut into 3 seperate pieces and are placed into an html table to display on the site.

I would like to be able to have the page randomly pick wich logo it would dispay, and have the 3 sepreate images be displayed acording to which one was selected...

thanks for the help

freak
04-18-2004, 06:14 AM
i have a web site that has 3 logos, Say A B and C, each one is cut into 3 seperate pieces and are placed into an html table to display on the site.

Some questions, first. Why are you using a table to display your header? Would an <h1> styled with CSS not suffice?


I would like to be able to have the page randomly pick wich logo it would dispay

Check out the following script: http://www.hiveware.com/imagerotator.php

// freak

me'
04-18-2004, 11:17 AM
http://www.alistapart.com/articles/randomizer/

Psychoman
05-15-2004, 12:12 AM
I thank you both, they do seem to work for one image at the time, but my 3 logos are cut into 3 pieces,

say
logo A has A1 A2 and A3
logo B has B1 B2 and B3
logo C has C1 C2 and C3

i can get them to all rotate, but i can't have the site display A1 C2 and B3 or any other combination... obviously i would need them to be picked and to have the other two parts be the corresponding parts

as for my header, if you notice, one of the images for the logo is on that cell, the table makes sure they are all in place... (i am trying to get my site up first, then i'll change it to DHTML positioning)

bradyj
05-15-2004, 12:25 AM
long way of doing it they taught me here, but this in your body before the images needed:


<?php
//start the random engine

srand ((double) microtime ()* 1000000 );
$i = rand (1,3);

// assign a value to the variables
//repeat the process for each content and link
switch( $i ){
case 1:
$Left = "<img src=\"images/A1.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Middle = "<img src=\"images/A2.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Right = "<img src=\"images/A3.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
break;
case 2:
$Left = "<img src=\"images/B1.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Middle = "<img src=\"images/B2.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Right = "<img src=\"images/B3.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
break;
case 3:
$Left = "<img src=\"images/C1.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Middle = "<img src=\"images/C2.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
$Right = "<img src=\"images/C3.jpg\" alt=\"Ski Display\" width=\"562\" height=\"357\" />" ;
break;
}
?>

In your Code you should have something like this:


<div>
<h3><?php echo $Left ; ?></h3>
<p><?php echo $Middle ; ?></p>
<p><?php echo $Right ; ?></p>
</div>


...or however you want to structure it. Remember in the PHP you should put those \ to block out the quotes -- you can adjust names and how many as you want, end the file name with a .php to call it up via your server

Psychoman
05-15-2004, 01:09 AM
Thank you, that seems perfect, i will try it as soon as possible



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum