#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    83
    Rep Power
    12

    writing a php statement to change a css style


    I have a header.inc file and a footer.inc file that is called to each new file that I create.

    The header.inc file holds all the javascripts as well as calls the css, etc. It also begins the body and the footer.inc file closes the body. In other words in each new file that I create I have a php statement calling the header, and at the bottom of the file another statement that calls the footer. So each new file is really only part of the body as the title and head are found in the header.inc file.

    What I would like to do is be able to change the background color of the body of a new file if I choose to do so. But obviously because each new file is only part of the body I cannot put a css style in the new file.

    Is there any way of writing a php statement that I can place in a new file that would allow me to change the background-color of let's say #faunabody for that particular page??.

    Hope this is clear...thanks alot
  2. #2
  3. AZbb founder
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    London, UK
    Posts
    843
    Rep Power
    11
    You can use different CSS for each variety i.e. if (this) then { that.css } etc. It can be done with JavaScript or PHP

    You can also output simple style tags for that one that you want. They would override the previous ones if they appear AFTER the call to the CSS and before </head>

    Example:

    Code:
    <!-- javascript stuff here -->
    <style type="text/css">
    <!--
    #faunabody { background: #ffffff; }
    -->
    </style>
    </head>
    <body>
    This is more a HTML/CSS question that PHP. You only use PHP to output the HTML.

    Good luck
    AZ

    AZbb :: AZ Bulletin Board - Secure BBS script, Front page CMS, Chat, No database
    Simple Guide to Apache and PHP installation on Windows
  4. #3
  5. I'm just an IF statement
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    400
    Rep Power
    12
    why would you want to go through all that trouble just to do that. just simple put <body bgcolor="#000000">
    "In a way, we're dead already"
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    36
    Rep Power
    11
    Maybe you could use

    page:
    PHP Code:
    <?php
    $background 
    "#FFFFFF";
    include 
    "header.inc";
    ?>
    page content
    <?php
    include "footer.inc";
    ?>
    header.inc:
    PHP Code:
    ...
    <style>
    #faunabody {
    background-color: <?php echo $background?>
    }
    </style>
    ...

IMN logo majestic logo threadwatch logo seochat tools logo