View Single Post
Old 01-18-2013, 06:02 PM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,517
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
my css file not picking up php variables??

Hi,

I read somewhere that I could use php to place
variables in my css style file to make it dynamic.

So I have a file called "a_style.php"

First I get my variables from the database, and manipulate them a bit:


PHP Code:
$cont 'n';    
$width "1000";
$widthpx $width.'px';

$margin $body_offset;
$marginpx $margin.'px';

$name_pospx $name_pos.'px';
$head_heightpx $head_height.'px';

$name_sizepx $name_size.'px';
$side_sizepx $side_size.'px'
Then I link my style file:

Code:
<Head>
<link rel='stylesheet' type='text/css' href='a_style.php' >
My code in the "a_style.php" is like this:

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

* {
    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; 
    }

When I run my script I noticed that my background color wasn't there
and then when I displayed the css file, I saw that the values were not
getting picked up.

The web page is:

http://professional-world.com

and the style sheet is:

http://professional-world.com/a_style.php


How do I remedy this ?

Thanks.


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote