title: show only three records and then move to next line
body: <p>This is a very basic problem but I am very new to PHP.
  I need to show results in such scenario that only three records in same line then add <code>&lt;br /&gt;</code> and then on next line, same thing should happend. I am unable to make its logic and in a great trouble :(
  Right now, I am just using the simple way i.e.</p>
  
  <pre><code>while($data = mysql_fetch_array($res_set)) {
  ?&gt;
   &lt;div&gt;&lt;?php echo $data['name']?&gt;&lt;img src="images/&lt;?php echo $data['image']?&gt;" /&gt;&lt;/div&gt;
  &lt;?php
  }
  </code></pre>
  
  <p>this is my code</p>
  
  <pre><code>$cnt = 0;
  
  while ($prd = mysql_fetch_array($res)) {
  
  ?&gt;
                  &lt;div class="imageRow"&gt;
                  &lt;?php
  
      $cat_id = $prd['cat_id'];
  $sql = "select * from tbl_category where id = $cat_id";
  $cat_res    = mysql_query($sql);
  $cat_data   = mysql_fetch_array($cat_res);
  $cat_name   =   $cat_data['name'];
  
  
  ?&gt;
  
                          &lt;div class="set"&gt;
                              &lt;div class="single first"&gt;
                                  &lt;a href="&lt;?php echo $ru ?&gt;admin/product_images/&lt;?php echo $cat_name ?&gt;/thumb/&lt;?php echo $prd['thumb_img'] ?&gt;" rel="lightbox[plants]"&gt;&lt;img src="&lt;?php echo $ru ?&gt;admin/product_images/&lt;?php echo $cat_name ?&gt;/large/&lt;?php echo $prd['thumb_img'] ?&gt;" style="height: 100px; width: 100px;" /&gt;&lt;/a&gt;&lt;br /&gt;
                                  &lt;a href="&lt;?php echo $ru ?&gt;contact_form.php?id=&lt;?php echo $prd['id'] ?&gt;"&gt;Choose&lt;/a&gt;
                              &lt;/div&gt;
  
  
                          &lt;/div&gt;
  
  &lt;/div&gt;
                  &lt;?php
                  $cnt = $cnt++;
                  if($cnt%3 == 0) {echo "&lt;br /&gt;";}
                  }
  
                  //echo  $cnt;
  
                  ?&gt;
  </code></pre>
  
  <p>any help will be appreciated.
  Thanks </p>