processing list of items in sections
<p>I want 3 item per div (the sample has a total of 7 items) like this:</p>

<pre><code>&lt;div&gt;
  &lt;item/&gt;
  &lt;item/&gt;
  &lt;item/&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;item/&gt;
  &lt;item/&gt;
&lt;/div&gt;
</code></pre>

<p>But I can't do</p>

<pre><code>while($r = mysql_fetch_array($q){
    ?&gt;&lt;item/&gt;&lt;?
}

if(++$i%3==1){ 
    //blabla:) 
}
</code></pre>

<p>Because it incorrectly prints out</p>

<pre><code>&lt;div&gt;
  &lt;item/&gt;
  &lt;item/&gt;
  &lt;item/&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;item/&gt;
...
</code></pre>

<p>How do I correctly print out the items in blocks of 3?</p>
