Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default Image rotator [PHP]

    PHP Code:
    <?php

    $img
    [0] = "images/box_red.png";
    $img[1] = "images/box_blue.png";
    $img[2] = "images/box_purple.png";
    $img[3] = "images/box_green.png";

    $total count($img) - 1;
    $rand rand(0,$total);

    echo 
    '<img src="$img[ $rand ]" border="0"';

    ?>
    That doesn't display what I want it to (images/box_xxxx.png). It displays the actual variable ($img[ $rand ]). +rep

    (using an edited version L?KE's code)
    Last edited by wsg14; 07-08-2008 at 03:11 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    England.
    Posts
    1,324
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by BOX! View Post
    PHP Code:
    <?php

    $img
    [0] = "images/box_red.png";
    $img[1] = "images/box_blue.png";
    $img[2] = "images/box_purple.png";
    $img[3] = "images/box_green.png";

    $total count($img) - 1;
    $rand rand(0,$total);

    echo 
    '<img src="$img[ $rand ]" border="0"';

    ?>
    That doesn't display what I want it to (images/box_xxxx.png). It displays the actual variable ($img[ $rand ]). +rep
    Oops, mod delete.

  3. #3
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    nvm. ^_^

  4. #4
    Join Date
    Apr 2008
    Location
    England.
    Posts
    1,324
    Tokens
    0

    Latest Awards:

    Default

    You also forgot the '> to end the src.

  5. #5
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php

    $img
    [0] = "images/box_red.png";
    $img[1] = "images/box_blue.png";
    $img[2] = "images/box_purple.png";
    $img[3] = "images/box_green.png";

    $total count($img) - 1;
    $rand rand(0,$total);

    echo 
    '<img src="'.$img$rand ].'" border="0" />';

    ?>
    Coming and going...
    Highers are getting the better of me

  6. #6
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Thanks Craig and Excellent.

  7. #7
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    if you want the .php file to be detected as an actual image so your can include it via <img src="..... just set the file as header("location:image.jpg");


    www.fragme.co = a project.

  8. #8
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Source View Post
    if you want the .php file to be detected as an actual image so your can include it via <img src="..... just set the file as header("location:image.jpg");
    No.. that would redirect the url to "image.jpg"
    Coming and going...
    Highers are getting the better of me

  9. #9
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    I was just going to ask that, how would I do that?

  10. #10
    Join Date
    Aug 2005
    Location
    London
    Posts
    9,773
    Tokens
    146

    Latest Awards:

    Default

    Quote Originally Posted by BOX! View Post
    I was just going to ask that, how would I do that?
    I believe it's
    PHP Code:
    header("Content-type: image/png"); 

Page 1 of 2 12 LastLast

Posting Permissions

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