Repeat loop within another repeat loop.
How can I do a repeat within another repeat?
I have a repeat loop for available product sizes in my product_details.php page which works great. It checks whether there are attribute sizes available for this particular product and if so, loops and displays those option names on the product_details.php page.
Here is the code for that:
<!--### Available SIZES ###-->
<?php if ($row_WADAproducts['ProductAttributeSize'] == '1') { ?>
<div class="clearfix">
<label class="pull-left">Sizes:</label>
<?php do { ?>
<?php echo $row_rsSize_2['OptionName']; ?> /
<?php } while ($row_rsSize_2 = mysql_fetch_assoc($rsSize_2)); ?>
</div>
<?php }?>
I like to display the same information also on the product_results.php page.
My challenge is that, in the products_results.php page, this repeat loop nests within another repeat loop that displays each individual product on the category page.
So when I simply paste the repeat and the recordset from the products_detail.php page into the products_results.php page = it only shows the option names of the first product on the page but not for the rest.
What do I have to change to make this work?
Here is my code for this portion of the products_result.php page:
<!-- ### START PRODDUCT DISPLAY ###-->
<?php do { ?>
<article class="col-xs-12 col-sm-12 col-md-4 col-lg-4 text-center">
<div class="product">
<figure class="figure-hover-overlay">
<a href="products_detail.php?ProductID=<?php echo($row_WADAproducts['ProductID']); ?>&SubCatID=<?php echo($row_rs_SubCategories['SubCatID']); ?>&CategoryID=<?php echo($row_rs_Categories['CategoryID']); ?>" class="figure-href"></a>
<img src="/images/products/<?php echo($row_WADAproducts['ProductImage']); ?>" alt="Image" class="img-responsive">
<span class="bar"></span>
<figcaption>
<a href="products_detail.php?ProductID=<?php echo($row_WADAproducts['ProductID']); ?>&SubCatID=<?php echo($row_rs_SubCategories['SubCatID']); ?>&CategoryID=<?php echo($row_rs_Categories['CategoryID']); ?>" class="shoping"><i class="glyphicon glyphicon-eye-open"></i></a>
</figcaption>
</figure>
<div class="product-caption">
<div class="product-name-2"><a href="products_detail.php?ProductID=<?php echo($row_WADAproducts['ProductID']); ?>&SubCatID=<?php echo($row_rs_SubCategories['SubCatID']); ?>&CategoryID=<?php echo($row_rs_Categories['CategoryID']); ?>" ><?php echo(isset($_GET["pageNum_WADAproducts"])?"&pageNum_WADAproducts=".intval($_GET["pageNum_WADAproducts"]):""); ?> <?php echo($row_WADAproducts['ProductName']); ?></a>
p class="product-name"><strong>
<?php if ($row_WADAproducts['ProductAttributeSize'] == '') echo $row_WADAproducts['ProductSize']; ?>
</strong> </p>
</div><span class="alert-success"><?php echo $row_WADAproducts['ProductPromoText']; ?><?php echo $row_WADAproducts['ProductPromoCode']; ?></span>
<!-- START OPTION NAME REPEAT -->
<?php if ($row_WADAproducts['ProductAttributeSize'] == '1') { ?>
<?php do { ?>
<?php echo $row_rsSize_2['OptionName']; ?> /
<?php } while ($row_rsSize_2 = mysql_fetch_assoc($rsSize_2)); ?><p class="custom_product_info">starting at only:</p>
<?php } ?>
<!-- END OPTION NAME REPEAT -->
<p class="product-price"><span><?php echo $row_WADAproducts['ProductSRP']; ?></span> $<?php echo $row_WADAproducts['ProductPrice']; ?></p>
<div class="product-specials">
<div class="stars">
<table width="90%" border="0" cellspacing="2" cellpadding="2" align="center">
<tr>
<?php if ($row_WADAproducts['ProductPrice'] > '99') { ?><td><div align="center"><img src="images/Icons/FreeShipping50x50.png" width="35" height="35" /></div></td><?php } ?>
<?php if ($row_WADAproducts['ProductFreeBonus'] == '1') { ?><td><div align="center"><img src="images/Icons/FreeBonus50x50.png" width="35" height="35" /></div></td><?php } ?>
<?php if ($row_WADAproducts['ProductSRP'] != '') { ?><td><div align="center"><img src="images/Icons/OnSale50x50.png" width="35" height="35" /></div></td><?php } ?>
</tr>
</table>
</div>
</div>
</div>
</div>
</article>
<?php } while ($row_WADAproducts = mysql_fetch_assoc($WADAproducts)); ?>
<!-- ### END PRODDUCT DISPLAY ###-->
Any pointers are appreciated.
Thanks a lot,
Joerg