PDA

View Full Version : Dynamic CSS problem



dave_c00
31 Oct 2006, 07:07 AM
I have a site by where i want to pass a different variable into a css file depending upon the page.
Currently i am using:-



<?
$pgcolor="#000000";
?>
<link href="style.php?pgcolor=<? echo $pgcolor;?>" type="text/css" rel="stylesheet">

and then within the css file style.php am using:-


<?php
header("Content-type: text/css");
$pgcol= $_GET['pgcolor'];
?>
body { color:<?=$pgcol?>; }
<?
?>

This isnt working for me.. Is there a way of doing it?

Thanks

gary[at]castus
03 Nov 2006, 04:09 AM
Have you done much PHP before and ever had any problems?

I would try changing all of the <? bits of code to <?php firstly ( i had a problem with this once)

and change

color:<?=$pgcol?>;

to:

color:<?php echo $pgcol; ?>