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

Thread: random fact

  1. #1
    Join Date
    Jul 2008
    Location
    in your pants.
    Posts
    1,747
    Tokens
    0

    Latest Awards:

    Default random fact

    how do you make a random fact generator on your website that changes everytime you reload the page? :\

  2. #2
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    Something like this would work I guess:

    PHP Code:
    <?PHP

    $facts 
    = array();

    $facts[0] = "In Australia, a dust-devil is called a \"willy-willy.\"";
    $facts[1] = "Back in 1919, the Russian transplant pioneer Serge Voronoff made headlines by grafting monkey testicles onto human males.";
    $facts[2] = "It takes eight and a half minutes for light to get from the sun to earth.";
    $facts[3] = "The United States Mint once considered producing donut-shaped coins.";
    $facts[4] = "Natural gas does not have any odor. In order to detect a gas leak, some gas companies add a chemical that smells similar like rotten eggs.";
    $facts[5] = "There are approximately 90 people that have been frozen after their death.";
    $facts[6] = "Japan uses the most energy per year than any other country.";
    $facts[7] = "A galactic year is 250 million Earth-years. This is the time it takes for our solar system to make one revolution around the Milky Way Galaxy.";
    $facts[8] = "By weight, the sun is 70% hydrogen, 28% helium, 1.5% carbon, nitrogen, and oxygen, and 0.5% all other elements.";
    $facts[9] = "Central air conditioners use 98% more energy than ceiling fans.";

    $number rand(0,9);

    echo 
    $facts[$number];
    ?>
    Last edited by Johno; 14-06-2009 at 11:37 AM.

  3. #3
    Join Date
    Jun 2009
    Location
    UK
    Posts
    112
    Tokens
    0

    Default

    Quote Originally Posted by Johno! View Post
    Something like this would work I guess:

    PHP Code:
    <?PHP

    $facts 
    = array();

    $facts[0] = "Yellow";
    $facts[1] = "Blue";
    $facts[2] = "Green";
    $facts[3] = "Pink";
    $facts[4] = "Purple";
    $facts[5] = "Maroon";
    $facts[6] = "Brown";

    $number rand(0,6);

    echo 
    $facts[$number];
    ?>
    Yeah that's a simple one, there are others out there, you just got to look and not be lazy.
    Habbo Name: Dye

  4. #4
    Join Date
    Jul 2008
    Location
    in your pants.
    Posts
    1,747
    Tokens
    0

    Latest Awards:

    Default

    I've been looking about for about 30 minutes, all I can actually find is countdown generators and stuff -.-

    + cheers Johno! +rep

  5. #5
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    No problem, replaced the original code with one with some actual facts

  6. #6
    Join Date
    Jul 2008
    Location
    in your pants.
    Posts
    1,747
    Tokens
    0

    Latest Awards:

    Default

    Sorta new to creating websites and such so im using an already coded template.

    How do I get the index page to display the fact generator? Ive saved it as a .php file already.

    Ive also edited the index page to show

    Code:
    <div id="banner"><iframe name="banner" id="banner" src="content/facts.php" width="100%" height="55" frameborder="0" allowtransparency="yes" scrolling="No"></iframe> </div>

  7. #7
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    I would just either put the code straight into the page (so paste the code where you want it to display) or use a php include.

    PHP Code:
    <?PHP include_once "content/facts.php"?>

  8. #8
    Join Date
    Jul 2008
    Location
    in your pants.
    Posts
    1,747
    Tokens
    0

    Latest Awards:

    Default

    but how do i put that in if I want it to keep in the same borders so it doesn't stretch the page?

    PHP Code:
    <div id="container">

    <
    div id="banner"><iframe name="banner" id="banner" src="content/news.html" width="100%" height="55" frameborder="0" allowtransparency="yes" scrolling="No"></iframe> </div>

    <
    div id="marquee"></div
    where can i put the php code in there? :S

  9. #9
    Join Date
    Feb 2006
    Location
    Scotland
    Posts
    2,087
    Tokens
    138

    Latest Awards:

    Default

    well you could define the width of the div it needs to be in and then set it so the fact marquee's

    PHP Code:
     <?PHP

    $facts 
    = array();

    $facts[0] = "In Australia, a dust-devil is called a \"willy-willy.\"";
    $facts[1] = "Back in 1919, the Russian transplant pioneer Serge Voronoff made headlines by grafting monkey testicles onto human males.";
    $facts[2] = "It takes eight and a half minutes for light to get from the sun to earth.";
    $facts[3] = "The United States Mint once considered producing donut-shaped coins.";
    $facts[4] = "Natural gas does not have any odor. In order to detect a gas leak, some gas companies add a chemical that smells similar like rotten eggs.";
    $facts[5] = "There are approximately 90 people that have been frozen after their death.";
    $facts[6] = "Japan uses the most energy per year than any other country.";
    $facts[7] = "A galactic year is 250 million Earth-years. This is the time it takes for our solar system to make one revolution around the Milky Way Galaxy.";
    $facts[8] = "By weight, the sun is 70% hydrogen, 28% helium, 1.5% carbon, nitrogen, and oxygen, and 0.5% all other elements.";
    $facts[9] = "Central air conditioners use 98% more energy than ceiling fans.";

    $number rand(0,9);

    echo 
    "<marquee>$facts[$number]</marquee>";
    ?>
    Do you have a live version of the website, PM me if you dont want to post it here

  10. #10
    Join Date
    Jan 2009
    Posts
    159
    Tokens
    0

    Default

    www.habbosolutions.net

    click 'webscripts' then 'custom scripts' and download the one on there, not the best but it's still one.

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
  •