How to limit number of lines per code? Hello all,

I currently spit out images from a DB into a new row. I want to limit the number of columns by 3 and create a new row.

How can I achieve this? Here is my HTML:

    &lt;table&gt;
        {% for item in img %}
        &lt;tr&gt;
        &lt;td&gt;
        &lt;img stuff&gt;&lt;checkbox stuff&gt;
        &lt;/td&gt;
        &lt;/tr&gt;
        {% endfor %}
    &lt;/table&gt;

Thanks!         
