tprofits
asked on
How can I change a div tag background color based on a database entry?
I am using PHP to populate a MySQL database with either 'yes', 'maybe', or 'no'. I want a CSS div tag to change color based on the database entry. For example:
if 'yes' >> green
if 'maybe' >> yellow
if 'no' >> red
I'm not sure where to start.
if 'yes' >> green
if 'maybe' >> yellow
if 'no' >> red
I'm not sure where to start.
Do have existing code... please post it
ASKER
I have my div tags:
<body>
<div id="weekend_avail">Jon</di v>
<div id="weekend_avail">Mike</d iv>
<div id="weekend_avail">Scott</ div>
<div id="weekend_avail">Todd</d iv>
</body>
I want my CSS background-color to change to #00FF00, #FFFF00, or #FF0000 based on whether the MySQL database is populated with 'yes', 'no', or 'maybe':
<head>
<style type="text/css">
<!--
#weekend_avail {
width: 300px;
height: 15px;
font-size: 12px;
background-color: #FFFFFF;
}
-->
</style>
</head>
<body>
<div id="weekend_avail">Jon</di
<div id="weekend_avail">Mike</d
<div id="weekend_avail">Scott</
<div id="weekend_avail">Todd</d
</body>
I want my CSS background-color to change to #00FF00, #FFFF00, or #FF0000 based on whether the MySQL database is populated with 'yes', 'no', or 'maybe':
<head>
<style type="text/css">
<!--
#weekend_avail {
width: 300px;
height: 15px;
font-size: 12px;
background-color: #FFFFFF;
}
-->
</style>
</head>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes. Yes. That makes sense! I'll try that out in the morning.
ASKER
Got me going in the right direction. Worked nicely.