Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl DB Access Correct Programming Check 1

Status
Not open for further replies.

skosterow

Technical User
Feb 23, 2002
135
US
Heya Guys and Gals -

Was wondering if the below script was the BEST way to do this -

Is there a way to get rid of $counter?

my $sth = $dbh->prepare(qq{ SELECT id, term FROM db_bill_terms ORDER BY id });
$sth->execute();
my $counter = 1;
while (($DB::ID, $DB::NAME) = $sth->fetchrow_array())
{
@NEW::BILLTERMS[$counter] = "<option value=\"$DB::ID\">$DB::NAME";
$counter = $counter + 1;
}
$sth->finish();
$dbh->disconnect();

thanks!

- Scott
 
Code:
while(($DB::ID, $DB::NAME) = $sth->fetchrow_array())
    {
      push (@NEW::BILLTERMS, "<option value=\"$DB::ID\">$DB::NAME");
    }
    $sth->finish();
    $dbh->disconnect();
should do it
HTH
--Paul


It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top