Well now that the rest of the code is up there I can tell you why you had a problem. You are incrementing count the first time you use it. So when you set $count = 0 , once you got to the echo statement $count became 1 because you are incrementing it already. Instead, you should use $count++ instead. If PHP is like C++ in that respect, the incrementation should occur after the rest of the statement is executed.
Glad to help. The difference between ++$count and $count++ is that in the first, the variable is incremented before the rest of the statement is interpreted, whereas with the latter, the value is incremented after.