title: Codeigniter looping inside another loop
body: <p>I have Main product category Listed Like </p>
  
  <ol>
  <li>Cake</li>
  <li>List item</li>
  <li>Bun</li>
  <li>Toffees</li>
  <li>Bread</li>
  </ol>
  
  <p>Under one Main product category there are sub products too. </p>
  
  <p>1 Cake 
   (1.1 Butter Cake)(1.2 Chocolate cake)</p>
  
  <p>On my view I echo these main Products only by using following code.</p>
  
  <pre><code>&lt;div class="row"&gt;
          &lt;?php if(isset($records)) : foreach($records as $row) : ?&gt;
              &lt;div class="span2"&gt;
                  &lt;p class="text-center subheader"&gt;&lt;?php echo $row-&gt;main_products_cat_name; ?&gt;
                  &lt;/p&gt;
                  &lt;p class="text-center"&gt;
                      &lt;a href="&lt;?php echo base_url()?&gt;product/all_product_data?id=&lt;?php echo $row-&gt;main_products_cat_id;?&gt;"&gt;&lt;img src="&lt;?php echo base_url(); ?&gt;assests/images/products/main_products/&lt;?php echo $row-&gt;main_products_cat_image; ?&gt;" alt="&lt;?php echo $row-&gt;main_products_cat_name; ?&gt;" width="200px" height="200px"&gt;
                      &lt;/a&gt;
                  &lt;/p&gt;
              &lt;/div&gt;          
          &lt;?php endforeach; ?&gt;
          &lt;?php endif; ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Can some one help me to echo Sub product category under Main Product.</p>