title: Php Nested loops showing repeated values
body: <p>I'm having a minute issue with nested loops.I've two tables product and product_option
  Every product has an option,price 
  Example Ring($25) with option red($.50) and yellow($.75).
  So the table is something like this product(id,price,description) and product_option(product_id,optionname,optionprice)
  When I fetch data from php the output should look something like this
  Ring($25)                              total -price 25.75
  red(.50),yellow(.25)</p>
  
  <p>But my output shown something like this</p>
  
  <p>Ring($25)<br>
  red(.50),red(.50)</p>
  
  <p>Below is the code</p>
  
  <pre><code>session_start();
  require_once './classes/cartclass.php';
   $val = new carts();
  
  While($cartContent = mysql_fetch_assoc($cartContents)) 
   {
   if($cartContent['ctsid']==session_id())
  {
   $cartid=$cartContent['ctid'];
  $subTotal += $cartContent['ctprice'] * $cartContent['ctqty'];
  echo  $cartContent['iname'];
  echo $cartContent['mprice'];
  echo  $cartContent['mdesc'];
  $count=mysql_num_rows($val-&gt;getCartopt($cartid));
  
  if($count&gt;0){
  
                 $CartOpt = mysql_fetch_assoc($val-&gt;getCartopt($cartid));
                  foreach($CartOpt  as $Cartopts){
  
                      echo $CartOpts."".$CartOpt['ctopname'];
                       $i++;
                      if($i==$count)
                          break;
  
                    }
  
                  }
          }
      }
  </code></pre>