How to add images to image gallery?

How to add images to image gallery?

My gallery is structured like:
  1. <div id="gallery">
  2.    <div class="galleryRow">
  3.        <div class="uPic">
  4.               <img />
  5.                <p> description </p> 
  6.        </div>
  7.     </div>
  8. </div>

I want to generate this thing entirely from data fetched from db. Each #galleryRow can have 4 .uPic -s, after that, I need to add another galleryRow and add pictures inside it, and so on.... Now I have never touched ajax in jQuery and I don't know how to do this in code.... I know I can add list items or predefined divs using append(), and for things like this, I can use clone()....but frankly speaking, I have no idea how to handle this structure. Please help me.