mysql_query("SELECT sum(qty) FROM table WHERE lid='" . $row['lid'] . "' AND transtype_id='ALL'"); Code (php): Should there be no records tagged with 'ALL', mysql returns a NULL. Instead of NULL, how do I make it return me a ZERO as in 0. Thanks.
what difference does it make? Do this instead: $sql=@mysql_query("SELECT sum(qty) FROM table WHERE lid='" . $row['lid'] . "' AND transtype_id='ALL'"); if (!$sql) exit; Code (markup):
Sorry.. I should have been more specific. I'm using the mysql_query command with Maani's PHP Chart. http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Data $chart [ 'chart_data' ][ $row1 ][ $count ]=mysql_query("SELECT sum(qty) FROM table WHERE lid='" . $row['lid'] . "' AND transtype_id='ALL'"); Code (php): If the query returns a NULL, the chart will be distorted.
Returns 0 if sum(qty) is null mysql_query("SELECT COALESCE(sum(qty),0) FROM table WHERE lid='" . $row['lid'] . "' AND transtype_id='ALL'");