<table width="251" height="42" border="1"> 
<?php 
   $count=0;
   while($rs=mysql_fetch_array($result)) {
      if($count % 3 == 0){
          echo '<tr>';
      }
      echo '<td>'.$rs[img].'</td>';
      if($count % 3 == 0){
          echo '</tr>';
      } 
      $count ++;
   };
?> 
</table>