I have a header.inc file and a footer.inc file that is called to each new file that I create.
The header.inc file holds all the javascripts as well as calls the css, etc. It also begins the body and the footer.inc file closes the body. In other words in each new file that I create I have a php statement calling the header, and at the bottom of the file another statement that calls the footer. So each new file is really only part of the body as the title and head are found in the header.inc file.
What I would like to do is be able to change the background color of the body of a new file if I choose to do so. But obviously because each new file is only part of the body I cannot put a css style in the new file.
Is there any way of writing a php statement that I can place in a new file that would allow me to change the background-color of let's say #faunabody for that particular page??.
Hope this is clear...thanks alot
writing a php statement to change a css style
Moderator: General Moderators
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
you could anywhere on the document put :
...even in the body
Code: Select all
<style>
background-color: somecolor;
</style>
or call a different stylesheet document:
<link href...I would think about doing somethin like this:
other.php :
I dunno if that will work as is, but hopefully you get the idea.

Code: Select all
<form action="other.php" method="post">
<input type="text" value="csstype">
</form>Code: Select all
<?php
$style = $_POST['csstype'];
switch($style){
case 'choice1':
$theFile = 'style1.css';
break;
case 'choice2':
$theFile = 'style2.css';
break;
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo $theFile; ?>" />I'd make the css file a .php file (yes, this is possible), and then include the css file with extra $_GET variables.
Such as:
<link rel="stylesheet" type="text/css" href="includes/css/file.php?page=main.php" />
Then within the file switch the background, or whatever, depending on the $_GET['page'] variable.
Such as:
<link rel="stylesheet" type="text/css" href="includes/css/file.php?page=main.php" />
Then within the file switch the background, or whatever, depending on the $_GET['page'] variable.