Mysql SUM always return 1 in php -


i'm running following mysql query in php.

$result = mysql_query("select sum(profit) customers;"); $sum_profit = mysql_num_rows($result); echo $sum_profit;" 

and response $sum_profit returning 1. while table profit has been filled following:

profit 0.00 1.00 1.00 0.00 11.28 

the type of profit column double(10, 2). there i'm missing?

mysql_num_rows() returns number of rows returnd query. in case 1 row. you're looking of functions returns result set. example mysql_fetch_row().

$result = mysql_query("select sum(profit) customers;"); $row = mysql_fetch_row($result); echo $row[0]; 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -