CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: General Discussions: General Questions:
Question about Perl

 



oem7110
New User

Apr 24, 2003, 9:16 PM

Post #1 of 5 (2913 views)
Question about Perl Can't Post

Could anyone tell me how to check whether following statement containing anything? If it contains nothing, what statement can I use to check it?

while (@row=$sth->fetchrow_array)

Thank you


Paul
Enthusiast

Apr 25, 2003, 2:10 AM

Post #2 of 5 (2912 views)
Re: [oem7110] Question about Perl [In reply to] Can't Post

Well if your query returned any rows then @rows will always contain something. If your query returned 0 rows then the while loop won't execute.


oem7110
New User

Apr 25, 2003, 7:46 AM

Post #3 of 5 (2907 views)
Re: [Paul] Question about Perl [In reply to] Can't Post

I would like to check whether following statement contains anything, if it contains nothing, I would like to display a message, such as there is no item available!!, it is the reason I need to check following statements contain anything. Could you give me any suggestion how to write a code to perform following function please?

If @row contain nothing then

display there is no item available!!

else

while (@row=$sth->fetchrow_array)

Thank you


Paul
Enthusiast

Apr 25, 2003, 8:52 AM

Post #4 of 5 (2904 views)
Re: [oem7110] Question about Perl [In reply to] Can't Post

You can't use @rows for that, try this:

if ($sth->rows) {
...
}
else {
# No results
}


oem7110
New User

Apr 25, 2003, 3:21 PM

Post #5 of 5 (2901 views)
Re: [Paul] Question about Perl [In reply to] Can't Post


In Reply To
Thank you Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives