Fixed startfrom in template links in header
[koha.git] / html-template / search.pl
1 #!/usr/bin/perl -w
2 use HTML::Template;
3 use strict;
4 require Exporter;
5 use C4::Database;
6 use CGI;
7  
8 my $query=new CGI;
9
10 my $templatename=$query->param('template');
11 my $startfrom=$query->param('startfrom');
12 ($startfrom) || ($startfrom=0);
13 ($templatename) || ($templatename='searchresults.tmpl');
14
15
16 my $dbh=&C4Connect;  
17
18
19 my $template = HTML::Template->new(filename => $templatename, die_on_bad_params => 0);
20
21 my @results;
22 my $sth=$dbh->prepare("select * from biblio where author like 's%' order by author limit $startfrom,20");
23 $sth->execute;
24 while (my $data=$sth->fetchrow_hashref){    
25     push @results, $data;
26 }
27
28
29
30 $template->param(startfrom => $startfrom);
31 $startfrom+=20;
32 $template->param(nextstartfrom => $startfrom);
33 $template->param(template => $templatename);
34 $template->param(SEARCH_RESULTS => \@results);
35
36 print "Content-Type: text/html\n\n", $template->output;