Script for random image or flash file?

Discussion in 'Programming' started by Johnburk, Nov 3, 2005.

  1. mitchandre

    mitchandre Peon

    Messages:
    313
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #21
    give me all the names of the images you are using and all the names of flash files your using.
     
    mitchandre, Nov 4, 2005 IP
  2. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #22
    names are:

    image0.jpg
    image1.jpg
    image2.jpg
    image3.jpg
    image4.jpg


    flash0.swf
    flash1.swf
    flash2.swf
    flash3.swf

    I also tried the following code, but get the following in my error log


    "File does not exist: /home/website/public_html/test/<"
    Code (markup):

    
    <?php 
    $r_swf[]="flash0.swf" 
    $r_swf[]="flash1.swf" 
    $r_swf[]="flash2.swf" 
    $swf = $r_swf[ rand(0,2) ]; 
    ?> 
    <embed name="Movie1" src="<? echo $swf; ?>" quality="high" bgcolor="#FFFFFF"
        width="269" height="367"
        type="application/x-shockwave-flash"
        pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
      </embed>
    
    PHP:
     
    Johnburk, Nov 4, 2005 IP
  3. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Put this in a php file, put in on your server

    <?php
    $random_number = rand(1,9);
    echo '<object width="550" height="400">
    <param name="movie" value="flash' . $random_number . '.swf">
    <embed src="flash' . $random_number . '.swf" width="550" height="400">
    </embed>
    </object>';
    ?> 
    PHP:
    Then add
    <iframe src="myflash.php" width="550" height="400" scrolling="no" frameborder="0">Sorry, your browser does not support IFrames!</iframe> 
    Code (markup):
    And it works. Only for flash, but it works :)
     
    Johnburk, Nov 4, 2005 IP
  4. mitchandre

    mitchandre Peon

    Messages:
    313
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #24
    This will incorporate both. ;)

    
    <?php
    $imageorflash = rand(1,2);
    If (imageorflash == 1){
    	$random_number = rand(0,3);
    	echo '<object width="550" height="400">
    	<param name="movie" value="flash' . $random_number . '.swf">
    	<embed src="flash' . $random_number . '.swf" width="550" height="400">
    	</embed>
    	</object>';
    	}
    else {
    	$random_integer = rand(0,4); // Assumes you have images from image0 to image4
    	echo '<img src="http://www.domain.com/image', $random_integer, '.jpg"></img>'; //point to the correct domain/folder, this assumes .jpg but can be easily changed
    	}
    ?>
    
    PHP:
     
    mitchandre, Nov 4, 2005 IP
  5. Johnburk

    Johnburk Peon

    Messages:
    777
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #25
    Thanks alot :D You have been so kind to help me
     
    Johnburk, Nov 4, 2005 IP
  6. mitchandre

    mitchandre Peon

    Messages:
    313
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #26
    did it work?
     
    mitchandre, Nov 4, 2005 IP