My DB Table is like this
   id | name | image
--------------------------------
   1  | aa   | a.jpg
--------------------------------
   2  | aa   | b.jpg
--------------------------------
   3  | bb   | c.jpg
--------------------------------
   4  | bb   | d.jpg
--------------------------------
   5  | aa   | e.jpg
--------------------------------
   6  | bb   | f.jpg
--------------------------------
   7  | aa   | g.jpg
--------------------------------
   8  | aa   | h.jpg
--------------------------------
   9  | aa   | i.jpg
And this is my html
<div id="first">
</div>
<div id="second">
</div>
<div id="third">
</div>
First I need to Select * from the table where name="aa" 
I know how to do this..
but I want to separate the columns to each div.. 
1st,4th,7th... ( 1 + (n-1)*3 ) images of name=aa GOES to div#first
2nd,5th,8th... ( 2 + (n-1)*3 ) images of name=aa GOES to div#second
3rd,6th,9th... ( 3 + (n-1)*3 ) images of name=aa GOES to div#third
Finally I need the result like this
<div id="first">
  a.jpg
  g.jpg
</div>
<div id="second">
  b.jpg
  h.jpg
</div>
<div id="third">
  e.jpg
  i.jpg
</div>
Please let me know , how to do this with PHP , MYSQL Sorry For My Bad English
 
     
    