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!

Trouble with nested repeat regions 1

Status
Not open for further replies.

filchak

Technical User
Nov 15, 2008
2
0
0
CA
Hi,

I would appreciate some new eyes on this.

I have attached a snippet of code from an insert into dB form I am working on. I am trying to nest a repeat region inside of another but what is hapenning is that while the first repeat region works fine, the second only repeats on the first iteration of the parent repeat region. Looking at the code, there does not seem to be a reason for this. Can anyne spot why this is happening or suggest a better way to do this?

Cheers,

Dave

Attach Code

<?php do { ?>
<tr bgcolor="<?php
if($SSAdv_m1%$SSAdv_change_every1==0 && $SSAdv_m1>0){
$SSAdv_k1++;
}
print $SSAdv_colors1[$SSAdv_k1%count($SSAdv_colors1)];
$SSAdv_m1++;
?>">
<td width="47%"><label for="airport_id"><?php echo $row_rsAirport['airport']; ?></label></td>
<td width="19%"><input name="airport_id_<?php echo $RepeatSelectionCounter_1; ?>" type="checkbox" id="airport_id_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rsAirport['airport_id']; ?>" <?php if (!(strcmp(undefined,WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, undefined)))) {echo "checked=\"checked\"";} ?> /></td>
<td><table border="0">

<tr>
<td><?php do { ?><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td><input name="service_id" type="checkbox" id="service_id" value="<?php echo $row_rsService['service_id']; ?>" /></td>
<td><?php echo $row_rsService['service']; ?></td>
</tr>

</table><?php } while ($row_rsService = mysql_fetch_assoc($rsService)); ?></td>
</tr>
</table> <label for="service_id_jet"></label></td>
</tr>
<?php } while ($row_rsAirport = mysql_fetch_assoc($rsAirport)
 
OK ... wht I was doing wrong here was that, once the sibling nested repeat finished, it was closing off the MySQL connection so in fact, only the first iteration of the repeat actually otpt all of the records. Every subsequent iteration only put the checkbox there ... and nothing else. To fix this, yo need to move the connection code for that record set, in this case rsService, down into the actual loop so that everytime the the next loop comes around, a new connection to the database would be opened using the rsServce recordset. This then outputs all the records and then closes the connection, and waits for it to come around again to do it all over until the parent repeat completes and exits.

Here is the code: (keep in mind that the connection code for the parent repeat is up in the head as well)

<table width="85%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Airport</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rsAirport['airport']; ?></td>
<td><input type="checkbox" name="airport_id" id="airport_id" value="<?php echo $row_rsAirport['airport_id']; ?>" /></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php mysql_select_db($database_conFSM2, $conFSM2);
$query_rsService = "SELECT * FROM service";
$rsService = mysql_query($query_rsService, $conFSM2) or die(mysql_error());
$row_rsService = mysql_fetch_assoc($rsService);
$totalRows_rsService = mysql_num_rows($rsService); ?>
<?php do { ?>
<tr>
<td><?php echo $row_rsService['service']; ?></td>
<td><input type="checkbox" name="service_id" id="service_id" value="<?php echo $row_rsService['service_id']; ?>" /></td>
</tr>
<?php } while ($row_rsService = mysql_fetch_assoc($rsService)); ?>
</table></td>
</tr>
<?php } while ($row_rsAirport = mysql_fetch_assoc($rsAirport)); ?>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top