Feedback from a query of results found

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
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

Feedback from a query of results found

Post by Calimero »

The Problem =

What is the code for PHP to recognize whether the query returned EMPTY SET - no results found


And if possible I would need it in IF - return(ed) empty set (), ELSE()
code.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Sorry, we're not slave coders. Try some by yourself and call for help, we offer help voluntarily. The idea you already have, all you'll ever need is here: [php_man]mysql[/php_man].

Regards,
Scorphus.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

PHP will have a function specific to your database that will return the numer of rows in a result set for a associated query, in the case of mysql it is mysql_num_rows()

So you can get the number of rows and if it is greater than zero do something, else do something different.
scorphus wrote: The idea you already have, all you'll ever need is here: [php_man]mysql[/php_man].
Assuming of course that it is a mysql database they are working with.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Of course, if MySQL is not the DataBase server used in the case, it becomes implied that one will browse the PHP Manual and look for some information regarded to the DB server in use.

Sorry if I seemed a bit rude in that last message ;)

Regards,
Scorphus.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

No, I wasn't suggesting that you were rude, I know what you were getting at. I was merely commenting on the assumption being made that it was a mysql databse that was being used. While your assumption is probably correct, there is always a chance that the user may be using something else.
Post Reply