Copy link to clipboard
Copied
Hi
I have a repeat region displaying a recordset. I would like to apply some form of conditional formatting if a result meets a certiain condition. In my code below, I would like the 'onsched' field to display according to a specific class if the result is less than 0:
<?php do { ?>
<td><?php echo $row_RSonsched['name']; ?></td>
<td><?php echo $row_RSonsched['predcurrent']; ?></td>
<td><?php echo $row_RSonsched['Emerging_Level']; ?></td>
<td><?php echo $row_RSonsched['onsched']; ?></td>
</tr>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
Being new to PHP, is there any way I can have the class '.clsgood' apply if the value of ['onsched'] is less than 0?
Many thanks for your help in advance
Copy link to clipboard
Copied
Try this:
<?php do { ?>
<td><?php echo $row_RSonsched['name']; ?></td>
<td><?php echo $row_RSonsched['predcurrent']; ?></td>
<td><?php echo $row_RSonsched['Emerging_Level']; ?></td>
<td<?php if( $row_RSonsched['onsched'] < 0) { ?> class="clsgood"<?php } ?>><?php echo $row_RSonsched['onsched']; ?></td>
</tr>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
Ed
Copy link to clipboard
Copied
Thanks very much for your help. I managed to get everything to happen using the following code:
<td class="hr1"><?php echo $row_RSonsched['name']; ?></td>
<td class="hr2"><?php echo $row_RSonsched['predcurrent']; ?></td>
<td class="hr1"><?php echo $row_RSonsched'Emerging Level']; ?></td>
<td> <?php if ($row_RSonsched['onsched'] > "0") echo '<span class="good">'.$row_RSonsched['onsched'].'</td>'; if ($row_RSonsched['onsched'] < "-0.79") echo '<span class="bad">'.$row_RSonsched['onsched'].'</td>';else echo '<span class="ok">'.$row_RSonsched['onsched'].'</td>';?> </td>
Where 'good', 'bad' and 'ok' are css classes that display red, green and amber
Many thanks again