How do I check if my query returned no rows

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Quacy
Forum Newbie
Posts: 1
Joined: Sun Jun 21, 2009 3:19 pm

How do I check if my query returned no rows

Post by Quacy »

I need to execute a snippet based on whether my query returned rows or is empty. Can you help me out?
Last edited by pickle on Fri Aug 14, 2009 5:48 pm, edited 1 time in total.
Reason: Stop user from YELLING AT THE BOARDS (removed all caps in subject)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How do I check if my query returned no rows

Post by pickle »

It's not polite to YELL AT THE BOARDS. WE CAN READ JUST FINE WHEN THE TEXT IS properly cased. I've updated your post accordingly.

Assuming you're using MySQL, look into mysql_num_rows() or preferably mysqli_num_rows()
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply