#!/usr/bin/perl use CGI qw(param); use DBIx::FullTextSearch; use DBIx::FullTextSearch::StopList; use DBI; use HTML::Template; my $dbh = DBI->connect('dbi:mysql:xxxx','xxxx','xxxxxx'); my $search = param("search"); my $fts = DBIx::FullTextSearch->open($dbh, 'fts_xxxx'); my @files = $fts->search($search); if (@files) { foreach $filename(@files){ $filename = substr($filename,0,-4); $sth = $dbh->prepare("SELECT id, title FROM resource WHERE id =?"); $sth->execute($filename); while ($ref = $sth->fetchrow_hashref()){ $title = $ref->{title}; $id = $ref->{id}; push @rows, { ID => $id, TITLE => $title }; } } } my $template = HTML::Template->new(filename => 'pg_search.tmpl'); $template->param(TAB_BG_MAIN => "#0B5875"); $template->param(TAB_BG_HEAD => "#6180BA"); $template->param(SEARCH => $search); $template->param(ROWS => \@rows); print "Content-type: text/html\n\n"; print $template->output;