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 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: PHP in CSS?

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

    Latest Awards:

    Default

    Add this to the top of your .css file (you can add more colours if you want)
    PHP Code:
    <?php
    $colour
    [] = "#FFCCCC";
    $colour[] = "#FFFFFF";
    $colour[] = "#000000";
    srand ((double) microtime() * 1000000);
    $colour2 rand(0,count($colour)-1);
    ?>
    Then to display a random colour use this (example)

    PHP Code:
    body  {background-color: <?php echo "$colour[$colour2]"?>;
    font-size: 12px;
    font-face: arial;
    }
    Lets set the stage on fire, and hollywood will be jealous.

  2. #12
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Can I use php in the .css?
    How could this hapen to meeeeeeeeeeeeeee?lol.

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

    Latest Awards:

    Default

    Quote Originally Posted by Reconix View Post
    Can I use php in the .css?
    I dont know, you should try it.
    Lets set the stage on fire, and hollywood will be jealous.

  4. #14
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Will do.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  5. #15
    Join Date
    Jan 2007
    Location
    Canada eh?
    Posts
    766
    Tokens
    75

    Default

    Make life easy for yourself:

    style.php
    PHP Code:
    <style type="text/css">
    body{
      color: <?=$_GET['color']?>;
    }
    </style>
    And to use the above what you could do is like....

    PHP Code:
    <?php
    require('style.php?color=red');
    ?>
    You don't necessarily have to do it like that but that is just an example of how you could do it. So basically just make it a php file and then include/require it instead of using a css link.

  6. #16
    Join Date
    Apr 2006
    Location
    West Midlands
    Posts
    3,384
    Tokens
    0

    Latest Awards:

    Default

    No you can't use php in a .css file. I believe you could do this by just using

    <style>
    CSS HERE
    </style>

    at the top of each php page as you would be able to put php inside that.


    Xbox Live: Jholder112233
    PS3 Online Tag: Josh-H

    Last.fm | Digg | Xbox.com

  7. #17
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Do this:

    style.php
    PHP Code:
    <?php
    header
    ("Content-type: text/css");
    ?>
    CSS HERE <?="with php aswell"?>
    Then just do

    HTML Code:
    <link href="style.php" rel="stylesheet" type="text/css" />

  8. #18
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Ahaha beat me to it! Grr.

Page 2 of 2 FirstFirst 12

Posting Permissions

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