SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member compphenom's Avatar
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with nested repeat regions

    I have a website with hundreds of products and each product will come in any number of 26 colors. I have a page set up where it almost works, however it is not displaying the first result at all. I have been staring at this code for days now, can anyone point out my mistake(s):

    Code:
    	  <?php
       $lastTFM_nest = "0";
    	do {
    	 $TFM_nest = $row_TricoProductsRecords['productID'];
    	 if ($lastTFM_nest != "0") {
    	  if ($lastTFM_nest != $TFM_nest) {
       ?>
    		 <tr>
    			 <td width="42%">
    		<p>Product ID: <?php echo $row_TricoProductsRecords['productID']; ?>					
    		<br>
    				<strong> <?php echo $row_TricoProductsRecords['title']; ?></strong>
    			  </p>
    	   </td>
    	   <td width="58%">
    		<select name="select">
    					 <?php echo $options; ?>
    					   </select>
    		<?php echo $TFM_nest; ?>
    	   </td>  
    	  </tr>
    	 <?php
    	  }
    	 }
    	 $options.="<option value=\"".$row_TricoProductsRecords['color']."\">".$row_TricoProductsRecords['color']."</option>"; 
    	   if ($lastTFM_nest != $TFM_nest) {
    		$lastTFM_nest = $TFM_nest;		
    	   }
    	 ?>
    	<?php } while ($row_TricoProductsRecords = mysql_fetch_array($TricoProductsRecords)); ?>
     
    The results can be seen at:
     
    http://www.tricosources.com/cgi-bin/...tegory=flowers
     
    TIA,
     
    Kevin

  2. #2
    The short answer is yes... Herbster's Avatar
    Join Date
    Oct 2001
    Location
    Bay City, Oregon
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <?php
    $lastTFM_nest = "0";
    do {
    $TFM_nest = $row_TricoProductsRecords['productID'];
    if ($lastTFM_nest != "0" ) {
    if ($lastTFM_nest != $TFM_nest) {
    ?>
    <tr>
    <td width="42%">
    <p>Product ID: <?php echo $row_TricoProductsRecords['productID']; ?> 
    <br>
    <strong> <?php echo $row_TricoProductsRecords['title']; ?></strong>
    </p>
    </td>
    <td width="58%">
    <select name="select">
    <?php echo $options; ?>
    </select>
    <?php echo $TFM_nest; ?>
    </td> 
    </tr>
    <?php
    }
    }
    $options.="<option value=\"".$row_TricoProductsRecords['color']."\">".$row_TricoProductsRecords['color']."</option>"; 
    if ($lastTFM_nest != $TFM_nest) {
    $lastTFM_nest = $TFM_nest; 
    }
    ?>
    <?php } while ($row_TricoProductsRecords = mysql_fetch_array($TricoProductsRecords)); ?>
    
    The results can be seen at:
    
    http://www.tricosources.com/cgi-bin/...tegory=flowers
    
    TIA,
    
    Kevin
    You set $lastTFM_nest to equal zero so the first time through your loop you exclude the value. $lastTFM_nest won't have an acceptable value until the second time through the loop.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •