I am trying to pick up records from a mySQL database. It works fine unless there is just one record, it will not do anything. I think I need a jump 'Begining of File' command (if it exists!) as my original 'fetchrow_hashref' moves onto the only record, can anyone help please?
------------------------------------------------------------
if(my $ref = $sth->fetchrow_hashref())
{
open(TEXTFILE, ">$username.txt"
while(my $ref = $sth->fetchrow_hashref())
{
print TEXTFILE "$ref->{'record'}";
print TEXTFILE "$ref->{'reference'}";
}
close(TEXTFILE);
}
else
{
print "No entries in DB";
}
------------------------------------------------------------
Thanks for your time and trouble.
------------------------------------------------------------
if(my $ref = $sth->fetchrow_hashref())
{
open(TEXTFILE, ">$username.txt"
while(my $ref = $sth->fetchrow_hashref())
{
print TEXTFILE "$ref->{'record'}";
print TEXTFILE "$ref->{'reference'}";
}
close(TEXTFILE);
}
else
{
print "No entries in DB";
}
------------------------------------------------------------
Thanks for your time and trouble.