I have two tables :
Table 1 (overall Score )
Table 2 (weekly score )
I have a leaderboard where I am echoing the overall score value from T
1) Join the the queries into one
select EmployeeTable.*,Table2.pointsRewarded as `weeklyDelta`
from EmployeeTable join Table2 on EmployeeTable.EmployeeID = Table2.EmployeeID
where Table2.WeekNumber = 'week1'
order by Total_points_Rewarded desc
2) Then give the employees with negative deltas a special class
<?php
while( $toprow2 = sqlsrv_fetch_array( $stmt3) ) {
echo "<div class='parent-div" .
($toprow2['weeklyDelta'] <= -10 ? " dropped" : "") .
"'><span class='rank'>" .
$toprow2['overallRank'] . "</span><span class='name'>" .
$toprow2['EmployeeName'] . "</span><span class='points'>" .
$toprow2['Total_points_Rewarded'] . "</span></div>";
} ?>
3) give those employees a style
.parent-div.dropped { color:red }