<?PHP // albums.php

    include("config.php");

    print_header();

    $result = albums();

    $prevchar = "";
    $albums;
    for ($i=1; $i<$result["ALBUMCOUNT"]; $i++) {
	$albums[$i] = ucfirst($result[$i]);
    }
    asort($albums, SORT_STRING);
    reset($albums);
    while (list($alnum, $title) = each($albums)) {
        $thischar = substr($title, 0, 1);
        if ($thischar != $prevchar) {
            if ($prevchar) {
                echo "</TABLE>";
            }
	    else
		$prevchar = chr(ord($thischar)-1);
	    for($linkchar = ord($prevchar) + 1; $linkchar <= ord($thischar) ; ++$linkchar)
		echo "<A NAME=\"".chr($linkchar)."\"></A>";
	    echo "<TABLE WIDTH=100%>";
	    $prevchar = $thischar;
        }
        echo "<TR><TD>";
        echo "<B><A TARGET=\"mp3tracks\" HREF=\"tracks.php?album=$alnum\">$title</A></B></TD>";
        echo "<TD ALIGN=right><A TITLE=\"Queue this album\" TARGET=\"mp3queue\" HREF=\"queue.php?album=$alnum\"><IMG SRC=\"image/add.gif\" BORDER=0 HEIGHT=15 WIDTH=15></A></TD></TR>\n";
    }
    echo "</TABLE>";

?>

