Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Need a code..

  1. #1
    Join Date
    Jun 2005
    Location
    Bournemouth
    Posts
    5,389
    Tokens
    2,166
    Habbo
    Meanies

    Latest Awards:

    Default Need a code..

    That randomizes content.
    So every time you reload the page, a different thing shows in a certain part of the layout.

    A bit like the old habbo spotlight thing on the homepage.

    Please

    cake


  2. #2
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    HTML Code:
    <script language="JavaScript">
    <!--
    function random_text()
    {};
    var random_text = new random_text();
    var number = 0;
    random_text[number++] = "Content 1 Goes Here"
    random_text[number++] = "Content 2 Goes Here"
    random_text[number++] = "Content 3 Goes Here"
    random_text[number++] = "Content 4 Goes Here"
    
    var random_number = Math.floor(Math.random() * number);
    
    document.write(random_text[random_number]);
    --></script>
    That should work
    Lets set the stage on fire, and hollywood will be jealous.

  3. #3
    Join Date
    Jun 2005
    Location
    Bournemouth
    Posts
    5,389
    Tokens
    2,166
    Habbo
    Meanies

    Latest Awards:

    Default

    tyvm

    +rep

    cake


  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Doing it via PHP would be better, tbh. (So that the content shows in older browsers).

    PHP Code:
    <?php

    $content
    ] = "Content piece 1";
    $content] = "Content piece 2";
    $content] = "Content piece 3";
    /* To add a new piece of content just copy the above code and change the '3' to a '4', etc */

    $rand rand1/* Change the "3" to the amount of different content pieces */);

    echo 
    $content[$rand];

    ?>
    That's not the best way to do it in PHP, but it still works :p
    Last edited by Invent; 27-07-2007 at 05:32 PM.

  5. #5
    Join Date
    Jun 2005
    Location
    Bournemouth
    Posts
    5,389
    Tokens
    2,166
    Habbo
    Meanies

    Latest Awards:

    Default

    Thanks to you both, but would you be able to do the full thing for me, which ever way i try it i do it wrong and don't really udnerstand php

    What i want is 10 different things to be randomized.
    So in each content bit can you put
    <a href="http://www.habbo.co.uk/home/NAME">NAME</a>
    andd
    <img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=NAME&action=wve&frame=3&direction =4&head_direction=4&gesture=sml&img_format=gif">
    Thanks
    Just i keep going wrong -stupid-
    +rep again to whoever does it first ;P

    cake


  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    <?php

    $habbo
    [1] = "Invent!";
    $habbo[2] = "ReviewDude";
    $habbo[3] = "Archivist";
    $habbo[4] = "iSocks";
    $habbo[5] = "Lost_Witness";
    $habbo[6] = "HelKat";
    $habbo[7] = "UKChaserAl";
    $habbo[8] = "Disarno";
    $habbo[9] = "RedTiz";
    $habbo[10] = "Heidster";

    /* No more editing needed! */

    $i "0";

    foreach (
    $habbo as $habbos) {
            
        
    $i++;

    }

    function 
    image$name )
    {

        echo( 
    '<a href="http://www.habbo.co.uk/home/'$name .'">'$name .'</a><br /><img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user='$name .'&action=wve&frame=3&direction=4&head_direction=4&gesture=sml&img_format=gif" alt="'$name.'" /></a>' );

    }


    $rand rand1$i );

    image$habbo$rand ] );

    ?>
    To change the current Habbo's just edit the text in the quotes. ( The
    PHP Code:
    "Invent!" 
    part )

    To add another Habbo just add:

    PHP Code:
    $habbo[11] = "Habbo Name"
    So basically you just change the number in the [] to the the number after the last entry.

    P.S: The above code is coded badly, I just made it in 2mins lol.
    Last edited by Invent; 27-07-2007 at 10:38 PM.

  7. #7
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Php version
    PHP Code:
    <?php

    // stuff to poke
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME </a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 1</a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 2</a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 3</a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 4</a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 5</a>';
    $stuff] = '<a href="http://www.habbo.co.uk/home/NAME">NAME 6</a>';
    $stuff] = '<img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=NAME&action=wve&frame=3&direction =4&head_direction=4&gesture=sml&img_format=gif">';
    $stuff] = '<img src="http://www.habbo.co.uk/habbo-imaging/avatarimage?user=NAME&action=wve&frame=3&direction =4&head_direction=4&gesture=sml&img_format=gif"> 2';

    //Dont poke this, it'll work, just change values above and add/remove from em
    $display=rand(0sizeof($stuff)-1); 
    echo 
    $stuff[$display];
    ?>

  8. #8
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Lmao, forgot about 'sizeof' and 'count'.

  9. #9
    Join Date
    Jun 2005
    Location
    Bournemouth
    Posts
    5,389
    Tokens
    2,166
    Habbo
    Meanies

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    Lmao, forgot about 'sizeof' and 'count'.
    Are they important?

    +rep to both btw
    Ty

    edit; need to spread before i can give to invent ;D

    cake


  10. #10
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Nah, its just a quicker way of doing all that $i stuff.

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
  •