A few comments:

1. You don't need to chomp CGI input.

2. A database is designed to do complex queries. We use databases so we don't have to do extra work in Perl to sort out the things we need. Instead, we only ask for what we need, and let the database do the grunt work for us (it's more efficient anyway):

my $name = param('name'); # you may want to prevent search metacharacters: $name =~ s/(\%|_)/\\$1/g; my $sth = $dbh->prepare( "select * from clients where name like ?" ); $sth->execute($name) or die "Whoops!"; while ($sth->fetchrow_hashref) { ... }
Of course, always use placeholders!

3. Who said something has to be in a textbox to submit to a form? Use <input type=hidden>. Each submit button would look something like this:

<form method=post> <input type=hidden name=action value="more_info"> <input type=hidden name=name value="whatever"> <input type=submit value="More Info"> </form>
I don't understand your "alternative" of storing values in a "hash array." Again, you shouldn't have to store anything special/extra in a Perl datastructure, you just need to know the right thing to ask the database so it gives you what you want, and in the format you need.

blokhead


In reply to Re: Database Search by blokhead
in thread Database Search by Anonymous Monk

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.