There are a number of looping constructs available within PHP and without much of a prompt in the first post we can't be very specific in helping you. However here are some starting points which might be useful:
Putting the ++ after returns the variable then increments it, having the ++ before increments it then returns the variable.
Meaning if you echo $a++, it will display $a then add it to one after is has passed it value. If you display ++$a, it will show the value of $a added by one.