Computing.Net > Forums > Web Development > empty resultset mysql

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

empty resultset mysql

Reply to Message Icon

Name: studix
Date: June 14, 2005 at 11:43:30 Pacific
OS: xp
CPU/Ram: 512
Comment:

HI all, Im trying to preform a test using a php script to test if a result set is empty or not. Ive sent the query but i need a test so that i can write either the results if any or a message stating that the query returned no results or in this case the database is empty.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Laler
Date: June 14, 2005 at 12:17:17 Pacific
Reply:

in this case the database is empty.

query result or database?

if it's a query result and since you're asking to "test" a result, I assume you know how to query.

To test, just do a:

$returned_rows = mysql_num_rows ($theQuery);

where $theQuery is your resource link identifier, like:

$theQuery = mysql_query("SELECT blah FROM blah");

then do a:

if ($returned_rows == 0){
echo 'do whatever when no rows returned here';
}else{
echo 'do whatever when ' . $returned_rows . 'rows returned here';
}

mysql_num_rows()


0

Response Number 2
Name: studix
Date: June 14, 2005 at 13:01:38 Pacific
Reply:

Thats great thanks! does just what i need. As u might have guessed im a beghiner.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: empty resultset mysql

Transfering MySQL database www.computing.net/answers/webdevel/transfering-mysql-database/3392.html

Return Message on PHP mysql query www.computing.net/answers/webdevel/return-message-on-php-mysql-query/3633.html

Php/mySql/Phorum problems www.computing.net/answers/webdevel/phpmysqlphorum-problems/932.html