PDA

View Full Version : Conditional Formatting


Chamark
03-30-2006, 07:56 PM
Is there a way to conditionally format table cells with color ( red/green) based on the results of a query/recordset. I want to create a dashboard showing either red if x <= a certain amount and green if x >= a certain amount.

Any help or point me in the direction is appreciated.

Creative Insanity
03-30-2006, 08:39 PM
what about
<?php if $a ="xx" echo "td bgcolor="blue"; ?>

mangofreak
03-30-2006, 08:42 PM
Look at this site:
http://dreamweaverfever.com/pain/dreamweavermx/stripedrows.asp

may help you with your question.

Chamark
03-30-2006, 09:04 PM
Thanks all... I found what I needed by creating a Multiple-IF template expression.

davidj
03-31-2006, 07:54 AM
i do this allot and use a switch which is defined in my DO { Loop

if you have it working then thats fine but if you want to know a better method let me know

domedia
03-31-2006, 02:01 PM
Thanks all... I found what I needed by creating a Multiple-IF template expression.
uhm.. I'm no expert but this doesn't sound right.
The query is in a string so you just need to write a functions that writes out all the TD's with proper CSS classname.

Actually, you could do it with Javascript as well :-) (Long live the DOM)

davidj
03-31-2006, 02:47 PM
if you have a table matrix already defined then creating td's is unnessessary

example of a simple class set and call....



<table>
<tr>
<td>header</td>
<td>header</td>
<td>header</td>
<td>header</td>
</tr>

<?php
do { // repeat region start

switch ($row['db_field'])
{
case 'aa': $css = 'class="no1"'; break;
case 'bb': $css = 'class="no2"'; break;
case 'cc': $css = 'class="no3"'; break;
case 'dd': $css = 'class="no4"'; break;
}
?>

<tr>
<td <?php echo $css; ?>>dynamic stuff</td>// setting the css class depending on value
<td >dynamic stuff</td>
<td >dynamic stuff</td>
<td >dynamic stuff</td>
</tr>
</table>