View Single Post
Old 01-18-2013, 08:08 PM   PM User | #7
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,454
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by jeddi View Post
Then I link my style file:

Code:
<Head>
<link rel='stylesheet' type='text/css' href='a_style.php' >
You are correct with everything to that point.

The problem is that your code in the "a_style.php" doesn't define the PHP variables before using them. The adjustment I have made below shows you where you need the extra code to get the styles to work.

PHP Code:
<?php
    header
("Content-type: text/css; charset: UTF-8");

 
// set values here or place these in an include
$body_font '';
$body_bk_col '';

?>

* {
    margin: 0;
    padding: 0;
    }

html{
   height:100%;
   font-family:<?php echo $body_font?>;
    }


.main {
    width:<?php echo $widthpx?>;
    padding:0 50px 0 50px; 
    background-color:#<?php echo $body_bk_col?>;    
    }
    
.main_img {
    width:<?php echo $widthpx?>;
    padding:0 50px 0 50px; 
    }
Possibly the only change you need is to move the include for the file that manipulates the values form the DB to include into the styles from the PHP file generating the HTML into the PHP file generating the CSS.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 01-18-2013 at 08:10 PM..
felgall is offline   Reply With Quote