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
Change background color according to sql entry
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Change background color according to sql entry
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>
<?php while(!$succeed = try()); ?>