develooper Front page | perl.dbi.users | Postings from February 2001

fetchrow_array() help

Thread Next
From:
Kevin Sheen
Date:
February 1, 2001 12:15
Subject:
fetchrow_array() help
Message ID:
5.0.2.1.0.20010201151120.01bffd30@mail.zbzoom.net
if ($select) {

        $dbh = DBI->connect( 'xxx', 'xxx', 'xxx' );
        $sth = $dbh->prepare ( $select )
                or die "Can't prepare SQL statement: $DBI::errstr\n";
        $sth->execute();
        print "<TABLE border=1>\n";
        while ( @row = $sth->fetchrow_array() ) {
                print "<TR ALIGN=Left>\n";
                for ($i=0; $i<$col; $i++) {
                        print "<TD>$row[i]</TD>";
                        }
                print "</TR>\n";
                }
        print "</TABLE>\n";
        $dbh->disconnect();
        }


The above code is generating the following:

acer, ken	acer, ken	acer, ken
allen, william	allen, william	allen, william
anonymous	anonymous	anonymous
atkinson, jennifer	atkinson, jennifer	atkinson, jennifer
auer customer	auer customer	auer customer

It would appear that printing out $row[i] isn't working or I'm doing it wrong (probably, the latter).  Does anyone have any suggestions?

thanks,

Kevin


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About