Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested loops not displaying properly

Status
Not open for further replies.

deeciple

Technical User
Mar 1, 2012
70
0
0
US
Hi All,

I am creating a report using tables and nested "do... while..." loops. On the inside loop, I have only the <tr> that I want to loop set within the "do... while..." statements but for some reason I am still getting the header and footer rows and table caption looping. I believe it has something to do with the fact that this is a nested loop but I can't quite figure out how to fix it.

Any help is welcome and appreciated. Here is the code:

PHP:
</TABLE>  
    <?php 
	$oldAirdate = "";
	$oldDiscrepType = "";
  $oldRecordNum = "";  
	do {
		$newAirdate =  $row_rstINIactivity['Airdate'];
		$newDiscrepType = $row_rstINIactivity['DiscrepType'];
    $newRecordNum = $row_rstINIactivity['tblOnAirActivityID'];
		?>
<table align="left" style="clear:right" >
  <tr>
    <TD width="15%" ALIGN=RIGHT  BGCOLOR=#FFFFFF ><I><FONT style=FONT-SIZE:12pt FACE="Calibri" COLOR=#000000><?php if ($oldAirdate <> $newAirdate) {echo $row_rstINIactivity['Airdate'];} ?></FONT></I></td>
    <td width="10%">&nbsp;</td>
    <td width="75%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <TD ALIGN=LEFT BGCOLOR=#FFFFFF ><U><FONT style=FONT-SIZE:11pt FACE="Calibri" COLOR=#000000><?php if ($oldDiscrepType <> $newDiscrepType) {echo $row_rstINIactivity['DiscrepType'] . "'s";} ?></FONT></U></I></TD>
  </tr>
  <tr <?php if ($oldRecordNum <> $newRecordNum) {echo "style='display: block'"; }else{ echo "style='display: none'";}?>>
    <td>&nbsp;</td>
    <TD ALIGN=left  BGCOLOR=#FFFFFF ><B><I><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['DiscrepDetail']; ?>&nbsp;&nbsp;</FONT></I></B></TD>
    <TD ALIGN=LEFT  BGCOLOR=#FFFFFF ><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['Description']; ?></FONT></TD>
  </tr>
  <tr <?php if ($oldRecordNum <> $newRecordNum) {echo "style='display: block'"; }else{ echo "style='display: none'";}?>>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <TD ALIGN=LEFT  BGCOLOR=#FFFFFF ><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['Resolution']; ?></FONT></TD>
  </tr>
  <tr <?php if ($oldRecordNum <> $newRecordNum) {echo "style='display: block'"; }else{ echo "style='display: none'";}?>>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <TD ALIGN=LEFT  BGCOLOR=#FFFFFF ><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['Author']; ?></FONT></TD>
  </tr>
</table>

<table id="vari" align="right" width="75%" border="0" <?php if ($row_rstINIactivity['OnAirVariance'] == -1) { echo "style='display: block'"; }else{ echo "style='display: none'";}?>>
  <caption><FONT style=FONT-SIZE:11pt FACE="Calibri" COLOR=#000000>
    Details of affected content:
  </FONT></caption>
  <tr>
    <th align="left" width="15%" scope="col"><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000>Start Time:</FONT></th>
    <th align="left" width="15%" scope="col"><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000>End Time:</FONT></th>
    <th align="left" width="15%" scope="col"><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000>Material ID:</FONT></th>
    <th align="left" width="40%" scope="col"><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000>Title:</FONT></th>
    <th align="left" width="15%" scope="col"><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000>Length:</FONT></th>
  </tr>
  <?php
    $parentRecordNum =  $row_rstINIactivity['tblOnAirActivityID'];
   do { 
    ?>
    <tr>
    <td><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['StartTime']; ?></FONT></td>
    <td><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['EndTime']; ?></FONT></td>
    <td><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['MaterialID']; ?></FONT></td>
    <td><FONT style=FONT-SIZE:9pt FACE="Calibri" COLOR=#000000><?php echo $row_rstINIactivity['Title']; ?></FONT></td>
    <td></td>
  </tr>
  <?php
  $childRecordNum =  $row_rstAffectedProg['tblOnAirActivityID'];
   } while (/*$row_rstINIactivity = mysql_fetch_assoc($rstINIactivity) && */ $parentRecordNum == $childRecordNum); 
  ?>
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>
</table>
<br/>
    <?php
	$oldAirdate = $row_rstINIactivity['Airdate'];
	$oldDiscrepType = $row_rstINIactivity['DiscrepType'];
  $oldRecordNum = $row_rstINIactivity['tblOnAirActivityID'];  
	} 
	while ($row_rstINIactivity = mysql_fetch_assoc($rstINIactivity)); ?>

Thanks,

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top