Hi All,

Spend few hours trying to figureout a way to print my field name with the 
returned field value without any success.  Looked in the websites but no 
clue.  Below is my code can anyone modify the code so it will print 
field_name_in_mysql_table and field_values that is in mysql?  I have 5 
fields in my table.

.
.
.
my $dbh = DBI->connect ( "DBI:mysql:test:localhost", "test", "*******",
{
        PrintError => 0,
        RaiseError => 0
}) or die "Can't connect to the database: $DBI::errstr\n";

my $sth = $dbh->prepare( "
SELECT * FROM incu_management WHERE person_id=1001 " )
        or die "can't preare SQL statement: $DBI::errstr\n";

$sth->execute ();

while ($ref = $sth->fetchrow_hashref) {
    foreach $key (keys %{$ref}) {
        print �$field_name(need help here)------ $ref->{$key}, �;
    }
    print "\n";
}

$dbh->disconnect;

Thanks in advance for any help.

David

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to