title: mapping of list with that particular data in the list
body: <p>I am trying to display a gallery page, where there are different tabbed list i.e Gallery Name which is being fetched from the database. Each of these is mapped with <code>data-list-id</code> <br>
  Now each gallery has a particular set of images in it. 
  The list looks like: <br>
  ALL <br>
  List 1 <br>
  List 2 <br>
  List 3 <br>
  Here's the HTML that would display the content of these List:</p>
  
  <pre><code>&lt;div class="full-gallery details-area"&gt;
      &lt;div class="gallery-1 gallery-all"&gt;
          &lt;a href="img/img1.jpg" data-ngthumb="img/img1.jpg"&gt;image1&lt;/a&gt;
          &lt;a href="img/img1.jpg" data-ngthumb="img/img1.jpg"&gt;image1&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The same is implemented with change in <code>gallery-1</code> to <code>gallery-2</code> , <code>gallery-3</code> which will map with the respective List. </p>
  
  <p>Now my job is to make it dynamic. I get the results but with a slight bug. <br>
  This is what I did in PHP:<br></p>
  
  <pre><code>&lt;?php
  $gallery_index=1;
  $id=$SITE['site_settings']-&gt;cloud_site_id;
  $gal="SELECT gallery_id, gallery_image_url from `cloud_site_gallery_images` where `cloud_site_id`= $id and gallery_image_status=1;";
  
  $res = $DB-&gt;query($gal);
  uasort($res,'cmp_by_gallery');?&gt;
  &lt;?php 
  $test=0;
  $temp=array();
  $temp[0]=$res[0]-&gt;gallery_id; ?&gt;
  &lt;div class="full-gallery details-area"&gt;
      &lt;?php
      foreach($res as $galleryList)
      { 
          if($temp[$test] != $galleryList-&gt;gallery_id)
          $gallery_index++;
      ?&gt;
          &lt;div class="gallery-&lt;?php echo $gallery_index; ?&gt; gallery-all"&gt; &lt;br&gt;
          &lt;a href="&lt;?php echo WWW_GALLERY_IMAGE_PATH.'original/'.$galleryList-&gt;gallery_image_url; ?&gt;" rel= "&lt;?php echo $galleryList-&gt;gallery_id; ?&gt;" data-ngthumb="&lt;?php echo WWW_GALLERY_IMAGE_PATH.'original/'.$galleryList-&gt;gallery_image_url; ?&gt;"&gt;image1&lt;/a&gt;
                  &lt;?php 
                  $temp[++$test]=$galleryList-&gt;gallery_id; 
                  ?&gt;
          &lt;/div&gt;
          &lt;?php 
  
      } ?&gt;
  </code></pre>
  
  <p>The result that I get with this is not the same as that in HTML. While the <code>$gallery_index</code> is 1, it should print all the images in the <code>gallery-1</code> and then it should increment to 2.</p>
  
  <p><code>&lt;div class="gallery-1 gallery-all nanogallery_theme_light nanogallery_thumbnails_label_align_center unselectable"&gt;</code></p>
  
  <p><code>&lt;/div&gt;</code>
  This is what I should get. Here all the images are clubbed into this <code>class=gallery-1</code> <br>
  But I get something like this:</p>
  
  <p><code>&lt;div class="gallery-1 gallery-all nanogallery_theme_light nanogallery_thumbnails_label_align_center"&gt;</code> <code>&lt;/div&gt;</code> <br>
  <code>&lt;div class="gallery-1 gallery-all nanogallery_theme_light nanogallery_thumbnails_label_align_center"&gt;</code> <code>&lt;/div&gt;</code></p>
  
  <p>Here every image comes as different <code>div</code> <br>
  I am not able to figure out the exact problem</p>
  
  <p>EDIT: </p>
  
  <pre><code>stdClass Object
  (
      [gallery_id] =&gt; 28
      [gallery_image_url] =&gt; Hydrangeas+1416289924.jpg
  )
  
  
   stdClass Object ( [gallery_id] =&gt; 28 [gallery_image_url] =&gt; Main+Qimg+D3344dabee4d48e5ee08eabff738f5dd+1416211112.png ) stdClass Object ( [gallery_id] =&gt; 28 [gallery_image_url] =&gt; Main+Qimg+A17a77318cc563cb43ae387170c79b75+1416211067.jpg ) stdClass Object ( [gallery_id] =&gt; 61 [gallery_image_url] =&gt; Img2+1416221089.jpg ) stdClass Object ( [gallery_id] =&gt; 61 [gallery_image_url] =&gt; Img1+1416221043.jpg ) stdClass Object ( [gallery_id] =&gt; 62 [gallery_image_url] =&gt; Koala+1416293951.jpg ) stdClass Object ( [gallery_id] =&gt; 62 [gallery_image_url] =&gt; Chrysanthemum+1416293916.jpg ) stdClass Object ( [gallery_id] =&gt; 62 [gallery_image_url] =&gt; Desert+1416288139.jpg ) stdClass Object ( [gallery_id] =&gt; 62 [gallery_image_url] =&gt; Lighthouse+1416293790.jpg ) stdClass Object ( [gallery_id] =&gt; 62 [gallery_image_url] =&gt; Tulips+1416293867.jpg )
  </code></pre>