Now using real data. Returns first 20 records where author starts with 's'
authortonnesen <tonnesen>
Fri, 10 May 2002 17:21:36 +0000 (17:21 +0000)
committertonnesen <tonnesen>
Fri, 10 May 2002 17:21:36 +0000 (17:21 +0000)
html-template/search.pl
html-template/searchresults.tmpl

index 91e4ed5..d728de4 100755 (executable)
@@ -1,16 +1,26 @@
 #!/usr/bin/perl -w
 use HTML::Template;
+use strict;
+require Exporter;
+use C4::Database;
+
+
+my $dbh=&C4Connect;  
+
 
 my $template = HTML::Template->new(filename => 'searchresults.tmpl', die_on_bad_params => 0);
 
-$template->param(PET => 'Allie');
-$template->param(NAME => 'Steve Tonnesen');
+my @results;
+my $sth=$dbh->prepare("select * from biblio where author like 's%' limit 20");
+$sth->execute;
+while (my $data=$sth->fetchrow_hashref){    
+    push @results, $data;
+}
+
+
 
 
-$template->param(SEARCH_RESULTS => [ { barcode => '123456789', title => 'Me and My Dog', author => 'Jack London', dewey => '452.32' },
-                                    { barcode => '153253216', title => 'Dogs in Canada', author => 'Jack London', dewey => '512.3' },
-                                    { barcode => '163214576', title => 'Howling at the Moon', author => 'Jack London', dewey => '476' }
-                                    ]
+$template->param(SEARCH_RESULTS => \@results
                );
 
 
index 56ab863..acd8a5f 100644 (file)
@@ -2,19 +2,13 @@
 <head><title>Test Template</title>
 </head>
 <body>
-Testing <TMPL_VAR NAME=NAME>
-<p>
-Pet's Name: <TMPL_VAR NAME=PET>
-<p>
-<hr>
 <table border=1>
-<tr><th>Barcode</th><th>Title</th><th>Author</th><th>Dewey</th></tr>
+<tr><th>Title</th><th>Author</th><th>Biblionumber</th></tr>
 <TMPL_LOOP NAME=SEARCH_RESULTS>
   <tr>
-  <td> <TMPL_VAR NAME=BARCODE> </td>
-  <td> <TMPL_VAR NAME=TITLE> </td>
-  <td> <TMPL_VAR NAME=AUTHOR> </td>
-  <td> <TMPL_VAR NAME=DEWEY> </td>
+  <td> <TMPL_VAR NAME=title> </td>
+  <td> <TMPL_VAR NAME=author> </td>
+  <td> <TMPL_VAR NAME=biblionumber> </td>
   </tr>
 </TMPL_LOOP>
 </table>