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? ?
天蓬老师2017-05-16 13:12:30
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']; // 想要的结果
巴扎黑2017-05-16 13:12:30
$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