poolboi has asked for the wisdom of the Perl Monks concerning the following question:
it prints the results from mysql if i find a match but say i am unable to find a match i want to output to users " sorry no matches found" i need a (if..else) statement..but how do i determine if the fetchrow_arrayref is empty in the condition of the if..else statement?$sth = $dbh->prepare("SELECT * FROM `mml log` WHERE Commands LIKE '%$I +MSI%'"); $sth->execute(); my $numFields = $sth->{'NUM_OF_FIELDS'}; while (my $ref = $sth->fetchrow_arrayref){ for (my $i=0; $i<$numFields; $i++){ printf ("%s %s", $i ? "," : "", $$ref[$i]); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to determine of fetchrow_Arrayref is empty?
by ysth (Canon) on May 27, 2008 at 02:09 UTC | |
|
Re: how to determine of fetchrow_Arrayref is empty?
by GrandFather (Saint) on May 27, 2008 at 02:01 UTC | |
by Herkum (Parson) on May 27, 2008 at 19:47 UTC | |
|
Re: how to determine of fetchrow_Arrayref is empty?
by doom (Deacon) on May 27, 2008 at 02:17 UTC | |
by ysth (Canon) on May 27, 2008 at 09:22 UTC | |
by doom (Deacon) on May 27, 2008 at 18:35 UTC | |
|
Re: how to determine of fetchrow_Arrayref is empty?
by hesco (Deacon) on May 27, 2008 at 07:09 UTC | |
by ysth (Canon) on May 27, 2008 at 09:30 UTC |