Why not do
div.content { border-style:solid; border-width:2px; border-color: #000; margin: 10px 0px; }
and then add an extra class to the div depending on the result of db, for example.
<div class="content <?php echo getContentClass($row) ?>"> ... </div>
where getContentClass() is a helper function that translates these booleans into meaningful CSS classes instead of specific color values.
function getContentClass(array $row) { return implode(' ', array_intersect_key( array( 'db_boolean_var1' => 'state1', 'db_boolean_var2' => 'state2', 'db_boolean_var3' => 'state3', 'db_boolean_var4' => 'state4' ), array_filter($row) )); }
Then just add these CSS classes to your regular stylesheet, e.g.
div.state1 { background-color: red; color: inherit }
Thus, everything is cleanly separated, and you do not need to resort to built-in styles.
Edit: note that class names as shown above do not make sense. Also not so cool names like red or black, because they are associated with the presentation. Try making them related to content, for example. something like invalid, errors, paid, free, active, etc.
source share