You've added an 's' to more places than I said ... should have been exactly one.
Here's the whole function again ...
/////////////////////////////////////////////////////////
function displaycontacts($result){
?>
<h1>phoenix contact list</h1>
<table>
<tr>
<th>url</th>
<th>email</th>
<th>Company</th>
<th>Category name</th>
</tr>
<?php
$bgcolors = array('white', 'yellow', '#C0C0FF');
$num_bgcolors = count($bgcolors); // ADDED 's' HERE
$counter = 0;
while($row = mysql_fetch_row($result)) { // FIXED brace '{' issue
$bgcolor = $bgcolor[($counter++) % $num_bgcolors];
?>
<tr>
<td bgcolor="'.$bgcolor.'"><?php echo join('</td>
<td bgcolor="'.$bgcolor.'">', $row); ?></td>
</tr>
<?php } ?>
</table>
<?php
}
/////////////////////////////////////////////////////////
% is called the modulus operator. It returns the remainder on integer division.
Take any two integers, m and n, say. (E.g. m=13 and n=3)
You can always find another two integers, called q (quotient) and r (remainder) so that ...
m = q*n + r ... where 0 <= r < n
E.g. We want 13 = q*3 + r ( where 0 <= r < 3)
Here, q = 4 and r = 1
Finally, m % n = r ... the remainder
The crucial thing is that ...
0 <= m % n < n
... so you've converted m into a number greater than zero but less than n.
In your case, suppose we put in an extra steps for clarity ...
$n = $num_bgcolors;
$m = ($counter++);
$r = $m % $n;
... and follow the variables in a table to see what's going on ...
+--+--+---------+-------------+
|$m|$n|$m%n = $r|$bgcolors[$r]|
+--+--+---------+-------------+
| 0| 3| 0%3 = 0 | white|
| 1| 3| 1%3 = 1 | yellow|
| 2| 3| 2%3 = 2 | #C0C0FF|
| 3| 3| 3%3 = 0 | white|
| 4| 3| 4%3 = 1 | yellow|
| 5| 3| 5%3 = 2 | #C0C0FF|
| 6| 3| 6%3 = 0 | white|
| 7| 3| 7%3 = 1 | yellow|
| 8| 3| 8%3 = 2 | #C0C0FF|
| 9| 3| 9%3 = 0 | white|
+--+--+---------+-------------+
... you can see that although $m (which is equal to ($counter++) remember) is getting bigger and bigger, we've still been able to use the % operator on it ($r = $m % $n) to cycle through the correct indices of the $bgcolors array (0, 1, 2, 0, 1, 2, ... etc)
Paul.