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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NotGiven

    #1

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

    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 { ?>
    <tr>
    <td><?php echo $row_rsAuthors['authorID']; ?>: <?php echo
    $row_rsAuthors['AUTHOR']; ?></td>
    <td>
    <?php
    mysql_data_seek ($rsBooks, 0);
    mysql_data_seek ($rsBooksSummar y, 0);
    $num_in_rsBooks = 0;
    do {
    if ($row_rsBooksSu mmary['authorID']==$row_rsAuthor s['authorID']){
    $num_in_rsBooks = $row_rsBooksSum mary["Count(book ID)"];
    }
    } while ($row_rsBooksSu mmary = mysql_fetch_ass oc($rsBooksSumm ary));
    if ($num_in_rsBook s!=0) {
    do {
    if ($row_rsBooks['authorID']==$row_rsAuthor s['authorID']){
    echo "<tr><td>";
    echo $row_rsBooks['TITLE'];
    echo "</td></tr>";
    }
    } while ($row_rsBooks = mysql_fetch_ass oc($rsBooks));
    }
    ?>
    </td>
    </tr>
    <?php } while ($row_rsAuthors = mysql_fetch_ass oc($rsAuthors)) ; ?>


Working...