Q:

Mysql SUM always return 1 in php

I'm running the following mysql query in php.
$result = mysql_query("SELECT SUM(profit) FROM customers;");
$sum_profit = mysql_num_rows($result);
echo $sum_profit;"

and the response $sum_profit is returning is always 1. This while the table profit has been filled with the following:
profit
0.00
1.00
1.00
0.00
11.28

The type of the profit column is double(10, 2). is there something I'm missing?

A:

mysql_num_rows() returns the number of rows returnd by your query. In this case it is one row. You're looking for any of the functions that returns a result set. An example would be mysql_fetch_row().
$result = mysql_query("SELECT SUM(profit) FROM customers;");
$row = mysql_fetch_row($result);
echo $row[0];

