Jump to content

Archived

This topic is now archived and is closed to further replies.

Cronje

Number of results problem

Recommended Posts

I'm trying to determine the number of results from a SELECT, but am having trouble. My code:
$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");
$num = mysql_num_rows($query);

It works fine when 'xxx' is in the table, but when it finds none, 'echo $num;' doesn't display anything.

Help please!

-Cronje

Share this post


Link to post
Share on other sites
How about this ?

$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");
$num = (int)mysql_num_rows($query);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.