#!/usr/bin/perl -W use CGI qw(param); use CGI::Carp qw(fatalsToBrowser); use DBIx::FullTextSearch; use DBIx::FullTextSearch::StopList; use DBI; use HTML::Template; use HTML::Template::Expr; my $dbh = DBI->connect('dbi:mysql:search','??????','??????') or die("Could not connect to database"); my $cbh = DBI->connect('dbi:mysql:cobra3','??????','??????') or die("Could not connect to database"); my $search = param("search_string"); my $fts = DBIx::FullTextSearch->open($dbh, '??????'); my @files = $fts->search($search); if (@files) { foreach $filename(@files){ $filename = substr($filename,0,-4); my $sth = $cbh->prepare("SELECT id, title, summary FROM resource WHERE id =?"); $sth->execute($filename); while (my $ref = $sth->fetchrow_hashref()){ my $title = $ref->{title}; my $id = $ref->{id}; push @rows, { ID => $id, TITLE => $title }; } } } my $template = HTML::Template->new(filename => 'ee_search.tmpl'); $template->param(SEARCH_STRING => $search); $template->param(ROWS => \@rows); print "Content-type: text/html\n\n"; print $template->output;