<?php
$db = mysql_connect("localhost", "root", "pass");
mysql_select_db("database",$db) or die ('Did not select Database');
$query = "SELECT * FROM songs ORDER BY genre, artist ASC";
$result = mysql_query($query);
$prev_genre = ''; // Initialize to something that wouldn't match the DB data
while ($row = mysql_fetch_assoc($result)) {
if ($prev_genre != $row['genre']) {
echo "<b>{$row['genre']}</b><br>"; // Display name once per genre
$prev_genre = $row['genre']; // Set to current genre
}
if ($prev_artist != $row['artist']) {
echo "{$row['artist']}<br>"; // Display name once per artist
$prev_artist = $row['artist']; // Set to current artist
}
echo "{$row['song']}<br>";
}
?>
thanks for your help. It worked just fine. this is the code i ended up using in case anyone needed it as well.