I've searched through older threads but haven't yet found a solution for the following issue: Is it possible to group and arrange mysql results without resorting to nested queries? Here's an approximate sample of how my results currently display:
Time 1 Station 1
Time 1 Station 2
Time 1 Station 3
Time 2 Station 1
Time 2 Station 2
etc.
I want them to display like this:
Time 1
- Station 1
- Station 2
- Station 3
Time 2
- Station 1
- Station 2
etc.
Here's an excerpt from my present code:
while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<li>\n";
echo "{$row['time']} at Station {$row['stationID']} ";
echo "<input type='radio' name='chooseTime' value='{$row['stationID']}~{$row['time']}~{$row['slotID']}'> Select</input>\n";
echo "</li>\n";
}
I'd prefer not to have to nest a loop to fetch the stations within the loop that fetches times, so is there a better/more efficient way?