At 01:28 16-11-03, you wrote:
It's so much easier to use the mod (%) operator:
Ah, the alternating rowcolors. I have a proposal that's a lot lighter on your server.
I prefer this as it does not require a calculation for each row (%2), and no counter (and no numrows call). I think it will be noticably faster with longer result sets. And your code is shorter.
$rowcolor=FALSE; //initialise
echo '<table>';
while(...walk trough resultset...) {
echo '<tr bgcolor="' .($rowcolor?'#FF0000':'#00ffff') .'" ><td>'.$somevalue.' </td></tr>';
$rowcolor=!$rowcolor; //toggles true/false and hence the row color }
echo '</table>';