Hi
Can anyone spot any errors with the below code? For some reason it doesn't want to print anything where it shoudl print $member->('name') - nothing appears although I know something should.
Thanks for any help you can give me.
$dbh = $mysql->connect_to_db;
$numrec = $dbh->selectrow_array("SELECT COUNT(*) FROM ata_offers");
$sth = $dbh->prepare("SELECT * FROM ata_offers");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref())
{
my $id = $ref->{'mem_id'};
$sql = $dbh->prepare("SELECT name FROM ata_members WHERE id = '$id'");
$sql->execute();
$member = $sth->fetchrow_hashref();
$sql->finish;
$offer_data .= qq|<tr bgcolor="#F4EFF7">
<td class="text-black" width="25%">$member->{'name'}</td>
<td class="text-black" width="57%">$ref->{'offer'}</td>
<td class="text-black" width="18%">$ref->{'offer_end'}</td>
</tr>
|;
}
$sth->finish;
$dbh->disconnect;
}
- wil
Can anyone spot any errors with the below code? For some reason it doesn't want to print anything where it shoudl print $member->('name') - nothing appears although I know something should.
Thanks for any help you can give me.
Code:
sub generate_offer_index { $dbh = $mysql->connect_to_db;
$numrec = $dbh->selectrow_array("SELECT COUNT(*) FROM ata_offers");
$sth = $dbh->prepare("SELECT * FROM ata_offers");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref())
{
my $id = $ref->{'mem_id'};
$sql = $dbh->prepare("SELECT name FROM ata_members WHERE id = '$id'");
$sql->execute();
$member = $sth->fetchrow_hashref();
$sql->finish;
$offer_data .= qq|<tr bgcolor="#F4EFF7">
<td class="text-black" width="25%">$member->{'name'}</td>
<td class="text-black" width="57%">$ref->{'offer'}</td>
<td class="text-black" width="18%">$ref->{'offer_end'}</td>
</tr>
|;
}
$sth->finish;
$dbh->disconnect;
}
- wil