Hi,
I am trying to slap together an index of a MySQL database using DBIx::FullTextSearch with a phrase type back-end and HTML::Template to display the results

I am trying to put the search string back into the the search box ( $template->param(SEARCH => $search);), which works fine apart from when I use a string in quotes i.e. to denote a phrase it puts nothing back into the search box

Interestingly enough if I print $search to the screen the quotes are intact

Here is my code

#!/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:xxxxx','xxxx','xxxxx'); my $search = param("search"); my $fts = DBIx::FullTextSearch->open($dbh, 'fts_cobra'); my @files = $fts->search($search); if (@files) { foreach $filename(@files){ $filename = substr($filename,0,-4); $sth = $dbh->prepare("SELECT id, title, summary FROM resource W +HERE id ='$filename'"); $sth->execute(); while ($ref = $sth->fetchrow_hashref()){ $title = $ref->{title}; $id = $ref->{id}; push @rows, { ID => $id, TITLE => $title }; } } } my $template = HTML::Template->new(filename => '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;


I bet this is a no-brainer for the average - and most of you will be wondering how I ever got this far - any comments even with 'sneers' will be greatly appreciated

Stew

p.s. anyone want to give me a clue how to take this further and add HTML::Pager functionallity will definately be considered for a Christmas Card :)

In reply to HTML::Template question by stew

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.