Anonymous Monk, I have put together a small search engine using ODBC, but I didn't use a hash to store my results. I embeded & called my
SELECT, generating all the html within a
while loop. Here is a stripped down version of what I used.
use DBI;
# Connect to the database
my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=database1.mdb';
my $dbh = DBI->connect("dbi:ODBC:$DSN") || die "Couldn't open database
+: $DBI::errstr;";
# Build a query
my $SQL1 = $dbh->prepare(<<End_SQL) || die "Couldnt prepare statement:
+ $DBI::errstr;";
select NAME_FIELD, TITLE_FIELD, EMAIL_FIELD FROM TBL_PEOPLE WHERE (TIT
+LE LIKE 'monk') ORDER BY NAME
End_SQL
# Execute the query
$SQL1->execute() || die "Couldn't execute statement: $DBI::errstr; sto
+pped";
while ( my ($resultField1, $resultField2, $resultField3) = $SQL1->fetc
+hrow_array() ) {
# perform any formatting/storage/etc with each record
}
# Disconnect from the database
$dbh->disconnect();
The fields which stored the information from
$SQL1->fetchrow_array() must coincide both in the number and order of the fields mentioned at the start of the
SELECT statement.
-
Big K
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.