...

View Full Version : php in CSS



zodehala
08-03-2008, 08:11 PM
i have a file is called as style.css (like following ) it is separate file (not in any file)


.table
{

color:#CC0000;
border-spacing:1;
padding:0;
border: 0px solid;
width:75%;
margin:1%;
text-align:center;
margin-left:auto;
margin-right:auto;
text-align:center;
}

some value will be read from db.for example color value is $tbl_color

is it possbile ?

scoop_987
08-03-2008, 09:27 PM
by making the file included, so it ran through the php parser. Thats the only way, so you will have you css printed in the source of the page.

Fou-Lu
08-03-2008, 09:53 PM
You're file will also need a .php extension or alteration in a .htaccess/http.conf file to include css as a php parsed file. I'd recommend sending a header at the top of you're css as well:


<?php
header("Content-type: text/css");
?>
body
{
...
}

This way you do not need to include the file as long as its independent (doesn't rely on anything generated in another file, or uses the same file as another file), and you should be able to call it the same way:
<link rel="stylesheet" type="text/css" href="mycss.php" />

Been awhile since I've used an external stylesheet with php, but I seem to recall doing it this way and it worked no problems.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum