Jump to content

CSS with PHP


gple

Recommended Posts

i have a CSS file named style.php and in there I have this code

 

tr.prod {

font-size:12px;

font-family: tahoma;

color: green;

}

 

tr.prod1 {

font-size:<?=$font_size?>px;

font-family:<?=$font_pref?>;

color:green;

}

 

when i use tr.prod, the font styles and such come out properly.

when i use tr.prod1, the font-size and font-family do not work properly but the color does. any reason for this. when i output the style sheet in my browser i see the correct values in prod1

Link to comment
Share on other sites

only when i define a variable (ie $color="green") does it output  the proper code. when i run a query and map a result to a variable that doesnt work (ie $color=mysql_result(...). BUt when I output the file, i see the results both appear properly.

Link to comment
Share on other sites

My guess is that he is calling the style.php file like this:

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

 

If so, then you have to input the correct headers within style.php to let the browser know that the data in the file is CSS and allow it to load properly, use the following header at the beginning of style.php if you are calling the way I expect you are.

 

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

 

Regards, PaulRyan.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.