Here's the thing. I'm trying to sort my Comics collection. So far, I have two tables, one for the titles and type of comics (ID, prefix, title, type) and another one with individual information for each issue (ID, title, volume, issue number, value).
First thing I do is associate the title from the issues with the appropriate titles from the title table.
I do something like that:
SELECT * FROM comics, comicstitles WHERE comics.comTitle = comicstitles.titID ORDER BY comicstitles.titTitle ASC
What I get is a neat bunch of rows that I organize, and I get results like:
<table class='simple-list'>
<thead>
<tr>
<th>Title</th>
<th>Volume</th>
<th>Issue</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alpha Flight</td>
<td>1</td>
<td>1</td>
<td>$4.00</td>
</tr>
<tr>
<td>Alpha Flight</td>
<td>1</td>
<td>2</td>
<td>$3.00</td>
</tr>
<tr>
<td>Machine Man</td>
<td>2</td>
<td>1</td>
<td>$2.00</td>
</tr>
<tr>
<td>Wolverine</td>
<td>1</td>
<td>2</td>
<td>$35.00</td>
</tr>
<tr>
<td>Wolverine</td>
<td>1</td>
<td>1</td>
<td>$60.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>115</td>
<td>$100.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>116</td>
<td>$100.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>111</td>
<td>$100.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>114</td>
<td>$100.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>109</td>
<td>$160.00</td>
</tr>
<tr>
<td>The X-Men</td>
<td>1</td>
<td>112</td>
<td>$100.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan='4'><h3>Total: $764.00</h3></td>
</tr>
</tfoot>
Now, what I would like to do is a foreach, which would give me something like:
For each title, print the title once and all the individual issues underneath.
I would end up with something like:
TITLE
Issue number
Cover
Issue number
Cover
TITLE
Issue number
Cover
TITLE
Issue number
Cover
Issue number
Cover
Issue number
Cover
Issue number
Cover
I tried looking over and over, but I always end up on Wordpress, Joomla or Drupal sites.
And any other results is either WAY too abstract or uses numbers.