gple Posted February 19, 2011 Share Posted February 19, 2011 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 https://forums.phpfreaks.com/topic/228220-css-with-php/ Share on other sites More sharing options...
gple Posted February 19, 2011 Author Share Posted February 19, 2011 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 https://forums.phpfreaks.com/topic/228220-css-with-php/#findComment-1176890 Share on other sites More sharing options...
ejscottb Posted February 20, 2011 Share Posted February 20, 2011 I think you have to use escape characters when using numbers naming classes in CSS. Numbers can give problems depending on your page code. Link to comment https://forums.phpfreaks.com/topic/228220-css-with-php/#findComment-1177014 Share on other sites More sharing options...
kenrbnsn Posted February 20, 2011 Share Posted February 20, 2011 Please post more of your code between tags. Ken Link to comment https://forums.phpfreaks.com/topic/228220-css-with-php/#findComment-1177031 Share on other sites More sharing options...
PaulRyan Posted February 20, 2011 Share Posted February 20, 2011 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 https://forums.phpfreaks.com/topic/228220-css-with-php/#findComment-1177034 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.