Hi all,
I wrote some code that I'm using to color text in a table across the diagonal from the top right to the bottom left of the table.
The code I wrote to do this is (psuedocode example):
$highlighter = 0;
$hrow = 9;
while ($row = [data set pulled from db]) {
[INDENT]echo "<TR><TD>".$row['data']."</TD>";
for ($i = 0; $i <= 9; $i++){
[INDENT]if ((($highlighter++) % 10) == $hrow { //highlight the text
echo "<TD bgcolor='#FFFFCC'>".$row['otherdata']."</TD>";
} else { //no hilight
echo "<TD>".$row['otherdata']."</TD>"
} //end if [/INDENT]
} // end for
echo "</TR>";
$hrow--; [/INDENT]
} // end while
Seems like one variable too many ($hrow or $highlighter), and the modulo calculation seems wonky, but I looked at it for quite a while and couldn't think of any other way. Anyone got a better idea?
Thanks.