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 5 of 5
  1. #1
    Join Date
    Apr 2009
    Posts
    4,289
    Tokens
    2,022
    Habbo
    iLogan

    Latest Awards:

    Default [PHP|Javascript] HELP!!

    At the moment on my page I've got YouTube playing one track,

    Code:
    <object width="0" height="0"><param name="movie" value="http://www.youtube.com/v/ST2H8FWDvEA?fs=1&amp;hl=en_GB&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ST2H8FWDvEA?fs=1&amp;hl=en_GB&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="0" height="0"></embed></object><br>
    Is there a PHP or Javascript piece of code so on refresh that code changes, so I can set different songs?

    Remel
    ex-hxl manager
    ex-event organizer
    ex-gfx designer
    ex-competition staff
    ex-content staff
    OFWGKΔ

  2. #2
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php
     
    echo rand(110); // 1 being the first track & 10 being the last 
    ?>
    enjoy

    Lew.
    Im not here to be loved, I love to be hated :-}


  3. #3
    Join Date
    Apr 2009
    Posts
    4,289
    Tokens
    2,022
    Habbo
    iLogan

    Latest Awards:

    Default

    Thanks -

    but where do you define what 1 - 10 is?
    ex-hxl manager
    ex-event organizer
    ex-gfx designer
    ex-competition staff
    ex-content staff
    OFWGKΔ

  4. #4
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by remel. View Post
    Thanks -

    but where do you define what 1 - 10 is?
    That is how you'd get a random number.

    Can you explain what exactly your trying to do then maybe I could help better.

    Lew.
    Im not here to be loved, I love to be hated :-}


  5. #5
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    PHP Code:
    <?php

    // Set the video id of each track
    // You can add as many tracks as you want and the count() function will adjust the range used in rand()
    $trackArray[] = 'ST2H8FWDvEA';
    $trackArray[] = 'ST2H8FWDvEA';
    $trackArray[] = 'ST2H8FWDvEA';
    $trackArray[] = 'ST2H8FWDvEA';
    $trackArray[] = 'ST2H8FWDvEA';

    // Select a random track
    $id rand(0count($trackArray));
    $track $trackArray[$id];

    echo 
    "<object width='0' height='0'><param name='movie' value='http://www.youtube.com/v/{$track}?fs=1&amp;hl=en_GB&autoplay=1'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/{$track}?fs=1&amp;hl=en_GB&autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='0' height='0'></embed></object><br>"

    ?>
    Not tested but it should work, although there's almost definitely a nicer way of doing it.
    I'm assuming you want it to be random, but I'm probably wrong.

Posting Permissions

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