Quote:
Originally posted by Darth Cow
Here is my current MySQL query...
SELECT SUM(hitscount) AS totalhits FROM hits WHERE time>123456789 AND siteid=10 GROUP BY siteid
This query works great most of the time, but sometimes there won't be any result rows that match the criteria. How would I make totalhits be equal to 0 if there are no results returned instead of a mysql resource result with no rows? Thanks for you help .
|
PHP Code:
$count['hits'] = 0;
if ( $docount = $DB_site->query_first("
SELECT COUNT(*) AS totalhits
FROM hits
WHERE dateline>$bbuserinfo[lastvisit] AND siteid=10
") and !empty( $docount['totalhits'] ) )
{
$count['hits'] = number_format( $docount['totalhits'] );
}