PHP newbie needs help with PHP/CSS to colour code sections

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MCR
Forum Newbie
Posts: 1
Joined: Mon Aug 03, 2009 6:04 am

PHP newbie needs help with PHP/CSS to colour code sections

Post by MCR »

I have written code in xhtml for a site the links to my CMS system and I want to automatically colour code each section of the site.

I am using template pages, where the same template serves each section I would like to link the css to a variable in the php code so that it defines the colour of various elements of the page in the css.

I am trying to avoid having to create 8 versions of the css, one for each section, as making changes in the future would be a pain

So - for example I can define SECTIONcolour=1 in the php and I want the css to treat this as a variable and display color: #808080;

See the following link
http://clientwebsites.co.uk/absolute/

I'm sure its simple for one of you talented coders!

Any help would be much appreciated.

Thanks

MCR
towerspl
Forum Newbie
Posts: 20
Joined: Mon Aug 03, 2009 7:37 am

Re: PHP newbie needs help with PHP/CSS to colour code sections

Post by towerspl »

have done this myself you would have to have your css in a php page with the following as a header:

Code: Select all

header("Content-type: text/css");

then its simply a php file so as i know you would have gathered but like the following:

Code: Select all

 
$current = intval($_GET['id']);
$current == 1 ? " color: green;" : "color: blue;";
 
hope that helps
Post Reply