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!


Results 1 to 4 of 4

Thread: Rotating Divs

  1. #1
    Join Date
    Mar 2007
    Location
    Portland/dorset
    Posts
    1,568
    Tokens
    0

    Latest Awards:

    Default Rotating Divs

    Well i have a box then i want everytime somone refresh it changes colour

    I have Blue, Green red

    Divs

    bluetop, bluemid, bluebot,
    greentop, greenmid, greenbot
    redtop, redmid, redbot

    is there anyway i can do this?
    Lets make the map red again

    T4 on the beach 2009 woo
    Need help PM me Im always happy to help, more then the guys at Asda

  2. #2
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    Something like this...?

    Code:
    <?php
    $random_color = rand(1,3);
    
    if ($random_color == 1) { 
    $color = 'blue';
    } elseif ($random_color == 2) { 
    $color = 'green';
    } else { 
    $color = 'red';
    }
    
    echo '<div class="'.$color.'top"></div>';
    echo '<div class="'.$color.'mid"></div>';
    echo '<div class="'.$color.'bot"></div>';
    
    ?>


  3. #3
    Join Date
    Jul 2008
    Posts
    5,289
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by DeejayMachoo View Post
    Something like this...?

    Code:
    <?php
    $random_color = rand(1,3);
     
    if ($random_color == 1) { 
    $color = 'blue';
    } elseif ($random_color == 2) { 
    $color = 'green';
    } else { 
    $color = 'red';
    }
     
    echo '<div class="'.$color.'top"></div>';
    echo '<div class="'.$color.'mid"></div>';
    echo '<div class="'.$color.'bot"></div>';
     
    ?>
    That would cause the same colour to be shown in a row occasionally?

    There would be a way via Cookies where it will choose a different colour than the last time.

    That is if your bothered about the same colour showing.

  4. #4
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    Quote Originally Posted by AlexOC View Post
    That would cause the same colour to be shown in a row occasionally?

    There would be a way via Cookies where it will choose a different colour than the last time.

    That is if your bothered about the same colour showing.
    Code:
    <?php
    session_start();
    $color = $_SESSION['color'];
    
    if ($color == '') { 
    $color = 'blue';
    $_SESSION['color'] = 1;
    } elseif ($color == 1)  {
    $color = 'green';
    $_SESSION['color'] = 2;$
    } elseif ($color == 2) { 
    $color = 'red';
    $_SESSION['color'] = '';
    } 
    
    echo '<div class="'.$color.'top"></div>';
    echo '<div class="'.$color.'mid"></div>';
    echo '<div class="'.$color.'bot"></div>';
    ?>


Posting Permissions

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