My boss wants me to write a script that will allow him to browse through the
customers in our DB alphabetically. He wants all the customer's information to
display on the page. I wrote the following as part of the script. I get the
error 'Can't coerce array into hash' at the first 'if' into the loop. What am I
doing wrong?
my $sth2 = $dbh->prepare("SELECT id FROM people ORDER BY lname, fname, mname");
$sth2->execute;
my $people = $sth2->fetchall_arrayref;
my $lastperson, $nextperson;
for my $lv (0..$#{$people}) {
if($people->[$lv]->{id} eq $id) {
if(!$lv) {
$lastperson = $people->[$lv-1]->{id};
} else {
$lastperson = -1;
}
if($lv != $#{$people}) {
$nextperson = $people->[$lv+1]->{id};
} else {
$nextperson = -1;
}
}
}
--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>