<& Template,top=>1 &>

<b>Searching by <%$mode%></b><P>

% if ($mode eq "artist" && scalar @found > 0) {
% foreach my $artist (@found) {
% my $artistlink = $artist;
% $artistlink =~ s/ /_/g;
<a href="artist?artist=<%$artistlink%>"><%$artist%></a><br>
% }
% } elsif ($mode eq "title" && scalar @found > 0) {
<table border=1><tr><th>Artist</th><th>Title</th><th>Price</th></tr>
% foreach my $id (@found) {
<& tools/cd_details,id=>$id,cds=>\%cds,table=>1 &>
% }
</table>
% } else {
<em>Sorry, but no results were found</em><p>
% }
<& Template,bottom=>1 &>

<%INIT>
my (@found);
my %cds = %{$m->comp('data/cds')};
my %artists = %{$m->comp('data/artists')};
if ($mode eq "title") {
   while (my ($id,$rec) = each %cds) {
      push @found,$id if $rec->{title}=~/$sstring/;
   }
} elsif ($mode eq "artist") {
  @found = grep /$sstring/, keys %artists;
} else {

}
</%INIT>

<%ARGS>
$sstring=>undef
$genre=>undef
$mode=>undef
</%ARGS>

