PHP data statistics sum
淡淡烟草味
淡淡烟草味 2017-05-16 13:10:29
0
3
670

How to count the sum of all the data in a certain field in the table, and how to output the result?

淡淡烟草味
淡淡烟草味

reply all(3)
洪涛

Thanks for the invitation

$updataquery = "select  sum(lv) AS the_result from gti_enews_technology_group" ;
$r=$empire->fetch1($updataquery);
print_r($r);


//打印的结果是Array ( [0] => 252 [the_result] => 252 )  打印看看是什么就好处理了
某草草

If it is MySQL, there are built-in functions directlySUM:

SELECT SUM(column) FROM table WHERE conditions;

Reference https://dev.mysql.com/doc/ref...

phpcn_u1582

If you directly use SQL statements to sum, it is not good if the data volume is large. Therefore, it is better to take out the value of this field first. If the amount of data is large, sum it up piece by piece and then integrate it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template