Mixing PHP and CSS Across Pages

Jijikokosss

New Member
I have a few pages which I'd like to have the same background across, so I figured an external style sheet would be the way to go. However, the background changes depending on the time of day, so I had to mix some PHP into the CSS. So now I have a file, background.php:\[code\]<html><style type="text/css">body{ background-image: url('<?php echo (day() == 1 ? 'images/day_sheep.jpg' : 'images/night_sheep.jpg'); ?>'); background-position: 50% 50%; background-repeat: no-repeat; background-color: silver}a {text-decoration:none;}a:link {color:#ff0000;}a:visited {color:#0000FF;}a:hover {text-decoration:underline;}</style></html>\[/code\]Which is being called from two different pages. One page works perfectly fine, but the other page completely broke when I added the line \[code\]require_once 'background.php'\[/code\], by which I mean nothing displays at all anymore. The offending page is as follows:\[code\]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Penelope's Conquests</title> <?php require_once 'background.php'; ?> <style type="text/css"> table { margin: 10px; margin-left: 50%; margin-right: 50%; padding: 12px; border: 10px; text-align: center; background-color: #fffb40; border-style: ridge; border-collapse: separate; border-color: #9c6ad6; outline-style: inset; } td.cap { text-transform: capitalize; font-variant: small-caps; } td.str { font-weight: bolder; font-size: 1.4em; } </style></head><body> <h2>To date, Queen Penelope has destroyed:<br /><br /></h2> <?php require_once 'victims.php'; require_once 'mysqlSheep.php'; echo '<table border="3" frame="box" cellpadding="5"> <caption>Penelope\'s Victims.</caption> <tr><th>Victim</th><th>Times Zapped</th>'; $hits = mysql_query(" SELECT * FROM victims ORDER BY amount "); if( $hits ) { while( $row = mysql_fetch_array($hits) ) { echo '<tr><td class="cap">'.$row['victim'].'</td> <td>'.$row['amount'].'</td></tr>'; } } else { echo '<p>' . mysql_error() . '</p>'; } echo '</tr></table><br /><br />'; echo '<table border="3" frame="box" cellpadding="5"> <caption>Button Clicks.</caption> <tr><th>Hour of day</th><th>Times Clicked</th>'; $time = mysql_query(" SELECT * FROM time ORDER BY hits "); while( $row = mysql_fetch_array($time) ) { print "<tr><td class='str'>".$row['hour']."</td>"; print "<td>".$row['hits']."</td></tr>"; } ?></body></html>\[/code\]Why doesn't the page want to behave with the style sheet?
 
Back
Top