You have a problem with namespaces. The "$i", that you use inside the section is not the same as you define in the first line.
See http://www.ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/basics/namespaces_
and note http://www.ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/functions/section If you just want a counter for the loop, you may use "index" or "number"