At 05:08 AM 08/20/2001 -0700, Keith & Rachel Murphy wrote:
>## fetch results and print
>
>while ( my @row = $sth->fetchrow_array() ) {
>
> ($id,$first_name, $last_name, $phone_number, $street_address, $city,
$state, $zip, $email) = @row;
> print center table ({-border=>5},
> Tr({-valign=>CENTER},
> [
> td(['First Name', $first_name]),
> td(['Last Name', $last_name]),
> td(['Phone Number', $phone_number]),
> td(['Street Address', $street_address]),
> td(['City', $city]),
> td(['State', $state]),
> td(['Zip', $zip]),
> td(['E-Mail', $email])
> ]
> ));
> print p;
>
>}
Also, on an unsolicited style/neatness note....I would use the
fetchrow_hashref method instead fetchrow_array. It eliminates the need to
load that temporary @row array, so you can just do something like this:
while ( my $hashref = $sth->fetchrow_hashref ) {
Tr({-valign='center'},
[
td( [ 'First Name', $hashref->{'Firstname') ] ),
td( [ 'Last Name', $hashref->{'Lastname') ] ),
td( [ 'Phone Number', $hashref->{'Phonenum') ] ),
]
));
print p;
...
Where the $hashref key is the original fieldname in your database. I find
this much easier to manage in my head than using temp arrays.
HTH...Aloha.
--
mel matsuoka Hawaiian Image Productions
Chief Executive Alphageek (vox)1.808.531.5474
[EMAIL PROTECTED] (fax)1.808.526.4040
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]