PHP field statistics sum
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 13:10:30
0
2
550

The problem is: Now we need to sum up all the data of the num field in the statistical table and output the total value.
Statistics can be executed using the SQL statement select sum(num) from table, but the problem is that I don’t know how to read the final result? ? ? Is there any great advice? ?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
Peter_Zhu

Try setting an alias for the result and you will be able to check it out

$sql = 'select sum(num) AS the_result from table';
$r = $db->query($sql);
$r['the_result']; // 想要的结果
巴扎黑
$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 )

The one upstairs should be fine

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