Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am not sufficiently familiar with the part about modifying contents on the webpage; sounds like Perl generating JavaScript to me.

Now, the DBI stuff, I can give you a working example:

Using SQLite to demonstrate:

C:\Steve\Dev\PerlMonks\P-2013-09-21@0144-DBI-Select-Example>"C:\App\SQ +Lite\sqlite3.exe" test.db SQLite version 3.3.5 Enter ".help" for instructions sqlite> CREATE TABLE FOO ( SEQNUM integer primary key, BAR character(3 +0) ); sqlite> insert into FOO values (1, 'George'); sqlite> insert into FOO values (2, 'Mike'); sqlite> .mode col sqlite> .header on sqlite> select * from FOO; SEQNUM BAR ---------- ---------- 1 George 2 Mike sqlite> .exit

And here's how you read the data into an array of hashes, which won't display on the output unless you make it happen:

#!/usr/bin/perl -w use strict; use DBI; my $TRUE = 1; my $FALSE = 0; my $Wrnflg = $TRUE; # Do we let warnings thro +ugh? # Establish WARN handler BEGIN { $SIG{'__WARN__'} = sub { warn $_[0] if $Wrnflg } } { # Set up SQLite DB filename and the SQL statement to execute my $Db_dbn = 'test.db'; my $sqlsmt = 'SELECT * FROM FOO;'; # A place to put the results my $retval = ''; # Set up presumed statistics my $dbargs = {AutoCommit => 0, PrintError => 1}; # Build connection string my $dbscns = "dbi:SQLite:dbname=$Db_dbn"; # Open the connection to the database server my $dbshan = DBI->connect($dbscns,"","",$dbargs); if ($dbshan->err()) { $retval = "$DBI::errstr"; # Do something with this error message. } # Prepare the SQL statement my $sqlhan = $dbshan->prepare($sqlsmt); if ($dbshan->err()) { $retval = "$DBI::errstr"; &debug::debug("\$retval = '\$retval'\n"); } my $qryres = $sqlhan->execute; if ($dbshan->err()) { $retval = "$DBI::errstr"; # Do something with this error message } # Fetch data my @dbrref = @{ $sqlhan->fetchall_arrayref({}) }; # Commit statement (not really an issue with SELECT but good as a +n example $dbshan->commit(); if ($dbshan->err()) { $retval = "$DBI::errstr"; # Do something with this error message } # Disconnect $dbshan->disconnect(); if ($dbshan->err()) { $retval = "$DBI::errstr"; # Do something with this error message } # Display foreach my $dbrref (@dbrref) { print "ROW:"; my %dbrrec = %$dbrref; foreach my $colnam (keys %dbrrec) { my $colval = $dbrrec{$colnam}; print " $colnam = '$colval'"; } print "\n"; } } exit; __END__

Results:

C:\Steve\Dev\PerlMonks\P-2013-09-21@0144-DBI-Select-Example>perl dbi-s +elect-example.pl ROW: SEQNUM = '1' BAR = 'George' ROW: SEQNUM = '2' BAR = 'Mike'

So all you have to do is not do the display loop

Cheers!


In reply to Re: Integration of SQL Search Results Into An Existing HTML Template by marinersk
in thread Integration of SQL Search Results Into An Existing HTML Template by Milti

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found