But what is 'alldata'? The row inside the loop will continually overwrite its own results, I suspect you actually want something more like:my $sql = "select name,address,phone,email from my table where name='m +ary'"; my $sth=$dbh->prepare($sql) or die "Couldn't prepare statement handle: + ".$dbh->errstr(); my $count=$sth->execute() or die "Couldn't execute statement:".$dbh->e +rrstr(); while (my @row=$sth->fetchrow_array()) { $AoH{ alldata } = join (' ', @row); } $sth->finish();
Oh, and of course, you'll be using placeholders in the real thing, right?push(@some_array, join(' ', @row));
my $sql="select name,address,phone,email from my table where name=?"; my $sth=$dbh->prepare($sql) or die "Couldn't prepare statement handle: + ".$dbh->errstr(); my $count=$sth->execute('mary') or die "Couldn't execute statement:".$ +dbh->errstr();
In reply to Re: Fetching DB using a While loop.
by leighsharpe
in thread Fetching DB using a While loop.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |