PCHomepage
Programmer
I have a relatively simple function that lists tracks of recordings and on occasion the recording is multiple-disk or on several sides if it happens to be vinyl. The function is working but I'm having a difficult time trying to figure out how to make the ordered list numbering start over for the second or more sides. The field Side is an integer value of the side: 1, 2, 3, 4 etc. If no side change, then it is always 1 for any given album.
The bit marked in red is the portion I can't figure out. Any ideas?
The bit marked in red is the portion I can't figure out. Any ideas?
Code:
function TrackListing ($RecordID, $DBconn) {
global $SongName;
if ($RecordID && $DBconn) {
$TracksAssigned = DLookup("TracksAssigned", "recordings", "ID=".$RecordID, $DBconn);
$PartialListing = DLookup("PsrtialListing", "song_assignments", "AssignID=".$TracksAssigned, $DBconn);
$TrackList = "<div class=\"HeaderCaptions\">Tracks</div>\n\n<div class=\"ListTracks\">\n";
if ($TracksAssigned) {
$Query = "SELECT s.Title, s.Composer, s.PlayTime, sa.ListCaption, sa.SubCaption, sa.Side, s.PrevUnreleased, r.SpecialTracks
FROM songs s, song_assignments sa, recordings r
WHERE TrackID = s.ID
AND AssignID = TracksAssigned
AND r.ID = $RecordID
ORDER BY Side, TrackOrder";
$DBconn->query($Query);
$TrackList .= ($PartialListing == 1) ? "<ul>":"<ol>";
while ($DBconn->next_record()) {
$Title = $DBconn->f("Title");
$Composer = $DBconn->f("Composer");
$Playtime = $DBconn->f("PlayTime");
$Unreleased = $DBconn->f("PrevUnreleased");
$ListCaption = $DBconn->f("ListCaption");
$SubCaption = $DBconn->f("SubCaption");
$Side = $DBconn->f("Side");
$SpecialTracks = $DBconn->f("SpecialTracks");
$Composer = ($Composer) ? " ($Composer)":"";
$Playtime = ($Playtime) ? " - $Playtime":"";
$PrevUnreleased = ($Unreleased == 1) ? " ***":"";
$TrackList .= ($ListCaption && $ListCaption != "NULL") ? "<p><strong>$ListCaption</strong>":"";
$TrackList .= ($SubCaption && $SubCaption != "NULL") ? "<strong>$SubCaption</strong>":"";
$TrackList .= "<li><strong>" . $Title . $PrevUnreleased . "</strong>" . $Composer . $Playtime . "</li>\n";
[COLOR=red]$TrackList .= (($ListCaption || $SubCaption != "NULL") && $PartialListing != 1 && $Side > 1) ? "</ol>\n\n<ol>": "</ul>\n\n<ul>";[/color]
}
} elseif ($SpecialTracks) {
$TrackList .= $SpecialTracks;
}
}
$TrackList .= ($PartialListing == 1) ? "</ul>\n\n":"</ol>\n\n";
$TrackList .= "</div>\n";
if ($Unreleased == 1) {
$TrackList .= "<p><strong>*** Previously unreleased</strong>";
}
return $TrackList;
}