solution to how I coded "nested repeat regions" or heirarchical displays

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

the code below assumes 3 result sets:
rsAuthors - authors table
rsBooks - book table
rsBooksSummary - summary of book table, Count(bookid) grouped by authorID

It displays something like this:

Jim Smith
                    One who flew over the clock tower
                    The hunting game

Roger Smtih
                    Polly wants a cracker house
                    Today is the day


<?php do { ?>
 <td><?php echo $row_rsAuthors['authorID']; ?>: <?php echo
$row_rsAuthors['AUTHOR']; ?></td>
 mysql_data_seek($rsBooks, 0);
 mysql_data_seek($rsBooksSummary, 0);
 $num_in_rsBooks = 0;
 do {
  if ($row_rsBooksSummary['authorID']==$row_rsAuthors['authorID']){
   $num_in_rsBooks = $row_rsBooksSummary["Count(bookID)"];
   } while ($row_rsBooksSummary = mysql_fetch_assoc($rsBooksSummary));
 if ($num_in_rsBooks!=0) {
  do {
   if ($row_rsBooks['authorID']==$row_rsAuthors['authorID']){
    echo "<tr><td>";
    echo $row_rsBooks['TITLE'];
    echo "</td></tr>";
    } while ($row_rsBooks = mysql_fetch_assoc($rsBooks));
<?php } while ($row_rsAuthors = mysql_fetch_assoc($rsAuthors)); ?>

Site Timeline