You need to stop using two queries and do it all in one query.
You should virtually NEVER have to nest one query inside the loop that results from another query. Doing so is horribly inefficient performance-wise and leads to just this kind of problem when you try to other more complex things.
*SOMETHING* like this:
Code:
<head>
<style type="text/css">
table#mainTable tr.odd {
background-color: ????;
}
table#mainTable tr.even {
background-color: ????;
}
table#mainTable td {
text-align: center;
... copy the event class style here ...
}
</style>
</head>
<body>
...
<table id="mainTable">
... header row ...
<?php
...
$query=" SELECT G.responsible_member,
G.total_wins,
( 4 * G.total_wins ) AS dollars_won,
B.bankRows,
IFNULL( B.bankAmount, 0 ) AS spentAmount,
( 4 * G.total_wins - IFNULL( B.bankAmount, 0 ) ) AS dollars_difference
FROM (
SELECT responsible_member, SUM(count_wins) AS total_wins
FROM our_game
WHERE responsible_member IS NOT NULL
AND count_wins IS NOT NULL
GROUP BY responsible_member ) AS G
LEFT JOIN (
SELECT member, COUNT(*) AS bankRows, SUM(-amount) AS bankAmount
FROM our_virtual_bank
WHERE amount = -2.00
GROUP BY member ) AS B
ON B.member = G.responsible_member
ORDER BY total_wins DESC, dollars_difference DESC, responsible_member ASC";
$result = mysql_query($query);
$rownum = 0;
while ( $row = mysql_fetch_array($result) )
{
$member = $row["responsible_member"];
$total_wins = $row["total_wins"];
$dollars_spent = $row["spentAmount"];
$bank
$dollars_won = $row["dollars_won"];
$dollars_difference = $row["dollars_difference"];
$font_color = ( $dollars_difference > 0 ) ? "#228B22" : "#FF0000";
echo ( $rownum & 1 != 0 ) ? '<tr class="odd">' : '<tr class="even">';
?>
<td width="" style="text-align: left;"><?php echo $row["responsible_member"]; ?></td>
<td width="16px"><?php echo $row["total_wins"]; ?></td>
<td width="16px"><?php echo $row["bankRows"]; ?></p></td>
<td width="30px">$<?php echo $row["spentAmount"]; ?></td>
<td width="30px">$<?php echo $row["dollars_won"]; ?></td>
<td width="30px" style="color: <?php echo $font_color; ?>">$ <?php echo $row["dollars_difference"]; ?></td>
</tr>
<?php
++$rownum;
}
?>
</table>
The SQL query there is a little bit of a guess, but not too much of one.
I'm not sure you need a LEFT JOIN; I suspect that an INNER JOIN would work fine. But if I wrote it right, the LEFT JOIN should work regardless.
Might be a typo or two in there. No way for me to test it out.
And of course I don't use PHP, so easy for me to typo in the PHP code.
*******
Simplify your HTML/CSS as well. There is no need for <p>...</p> tags inside of <td>...</td>. Just create the correct class for the <td> and get rid of the <p>.
And since all except your first <td> in each row are centered, do that in the CSS as well.