Well, for starters, do this before the while loop:
echo "<br>DEBUG: The number of returned rows is ".mysql_num_rows($result)."<br>";
Make sure there are actually 9 rows being returned.
Also, the fact that you're starting with a value of 0 instead of 1 now will affect your modulus check. You will need to re-evaluate the way you're checking the row.
I have to head out now, so good luck.