Page 1 of 1

Change background color according to sql entry

Posted: Wed Apr 10, 2013 11:33 am
by Smithers
Hello,
I was wondering if it's possible to change the background color of a page depending on the sql entry. For example if I have 3 sql entries: 1 is drinking, 2 is eating, 3 is sleeping; the user chooses drinking, he will see the page in blue, he chooses sleeping, it would be red. I would be very grateful for any help.
Many Thanks

Re: Change background color according to sql entry

Posted: Wed Apr 10, 2013 12:55 pm
by ExtremeGaming
You will need to query your database, and then just use the info to change the css in the head according to the results.
<?php
// $row is from mysql_fetch_something()
// And of course you would have a default theme using else, but this is just an example
if($row['theme'] == "sleeping") { $color = "red"; }
?>

<style>
body { background-color: <?php echo $color; ?> }
</style>