Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Florida, USA
    Posts
    275
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Randomly choosing an image

    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

  • #2
    New Coder
    Join Date
    Dec 2003
    Location
    California
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Psychoman
    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?

    Quote Originally Posted by Psychoman
    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

  • #3
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #4
    Regular Coder
    Join Date
    Feb 2004
    Location
    Florida, USA
    Posts
    275
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    long way of doing it they taught me here, but this in your body before the images needed:
    PHP Code:
    <?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:
    Code:
    	<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
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #6
    Regular Coder
    Join Date
    Feb 2004
    Location
    Florida, USA
    Posts
    275
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, that seems perfect, i will try it as soon as possible


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •