Home: Perl Programming Help: DBI:
What is no results found.



newbiecoder
Novice

Feb 9, 2003, 7:37 AM


Views: 6212
What is no results found.

Hi,
I've been looking through all the dbi documentation, loads of FAQ sites about dbi etc... But none seem to mention what to do when no results are found to your query.

$query = qq(SELECT field1, field2, etc FROM database WHERE email = "$email");

When I run my query, if the record being looked for is found, everything works correctly. However, if the record isn't found, it doesn't display anything.

How can I return a no record found message?

I'm probably being really stupid and missing something obvious but any help is very much appreciated!

Chris


Paul
Enthusiast

Feb 10, 2003, 3:40 AM


Views: 6207
Re: [newbiecoder] What is no results found.

We need to see more code than just the query.

However you are fetching the rows then just do an if/else.


Code
my @row = $sth->fetchrow; 

if (scalar @row) {

}
else {

}