#Search Records & Return Found 3 buttons # 0 Member ID # 1 Last Name # 2 Business Name elsif ($action eq "updatetable_167"){ warn("Entered updatetable_167"); my $kind = $query->param('kind'); my $searchterm = $query->param('searchterm'); my $result; warn("searchterm = '$searchterm'"); my $searchfield = ""; if ($kind == 0) { $searchfield = 'user_id'; } if ($kind == 1) { $searchfield = 'lastname'; } if ($kind == 2) { $searchfield = 'business'; } warn("searchfield = '$searchfield'"); # my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; comment +out for testing my $stmt = "SELECT * FROM users WHERE user_id = 15"; warn("statement = '$stmt'"); #of course meaning nothing with +placeholder ? my $sth = $dbh->prepare ($stmt) or die "Error Preparing:\n" . $stm +t . "\nDBI returned: \n", $dbh->errstr; $sth->execute($searchterm) or die "Unable to execute query: " . $s +th->errstr; warn("Finished sub search record"); $result = generateResponseHash($sth); # code # below is used to populate an html table and sent back to th +e client. Works fine for testing # $result = generateMemberDataSet($sth); if ($result == 1) { warn("Failed Search: '$searchfield' equal to '$searchterm' "); } }
sub generateResponseHash{ my $sth = shift; $sth->execute () or die "Unable to execute query: " . $sth->errstr; my $count = $sth->rows; warn("count = '$count'"); if ($count == 0) { return 1; } my $ref = $sth->fetchrow_hashref (); # print "Hello Output File\n"; #test stdout redirect to dumper.log w +orks. warn("generateResponseHash ref: '$ref'"); my $hash = hash_display_listing ($ref); $sth->finish (); completeResultHash( $hash ); }

Looks like sub below doe not generate a hash form the data supplied.

sub hash_display_listing{ my $ref = @_; #warn("hash display_listing: '$ref->{"id"}'"); my $hash = ( 'id' =>$ref->{"id"}, 'user_id' =>$ref->{"user_id"}, 'username' =>$ref->{"username"}, 'password' =>$ref->{"password"}, 'pin' =>$ref->{"pin"}, 'position' =>$ref->{"position"}, 'forename' =>$ref->{"forename"}, 'lastname' =>$ref->{"lastname"}, 'business' =>$ref->{"business"}, 'address1' =>$ref->{"address1"}, 'address2' =>$ref->{"address2"}, 'city' =>$ref->{"city"}, 'state' =>$ref->{"state"}, 'zip' =>$ref->{"zip"}, 'phone_home'=>$ref->{"phone_home"}, 'phone_cell'=>$ref->{"phone_cell"}, 'email' =>$ref->{"email"}, 'comments' =>$ref->{"comments"}, 'MJ' =>$ref->{"MJ"}, 'MD' =>$ref->{"MD"}, 'DD' =>$ref->{"DD"}, 'DP' =>$ref->{"DP"}, ); print Dumper ($hash);
my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; warn("statement = '$stmt'"); my $sth = $dbh->prepare ($stmt) or die "Error Preparing:\n" . $stm +t . "\nDBI returned: \n", $dbh->errstr; $sth->execute($searchterm) or die "Unable to execute query: " . $s +th->errstr;

Using the placeholder ? in select I get "1" printed the dumper.log HELP!!!


In reply to Re^10: CGI Action call by tultalk
in thread CGI Action call by tultalk

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.