|
Posted by davek on 10/17/06 13:02
I have a diary page listing social events in a table (stored in a mysql
db). If there are no current listings, I want to display a message
rather than an empty table.
This is the code I'm using:
**********
$query = @mysql_query('SELECT COUNT(*) FROM socials');
$count = @mysql_num_rows($query);
if ($count<1) {
echo ('<p>There are no forthcoming social events.</p>');
} else {
//show social events
}
**********
Unfortunately, this returns 1 when there are no results. It also
returns 1 when there is one result.
I'm probably being really dense and missing something obvious, but is
there a way to make it return 0 when there are no results? Or is there
a better approach to this task?
Any help much appreciated,
d.
Navigation:
[Reply to this message]
|