douqun1977 2012-11-28 07:14
浏览 62

如何在mysql的php循环中对项进行求和

<?php
    $query2 = QModel::query("SELECT * FROM transaction");
    while($get2 = QModel::g($query2)) {
        $totalprice = $get2['price'];
        echo array_sum($totalprice);
    }
?>

I get php error:

Message: array_sum() expects parameter 1 to be array, string given

please help thanks

  • 写回答

6条回答 默认 最新

  • dougan0529 2012-11-28 07:17
    关注

    you can use like this :

    $totalprice += $get1['price'];
    
    评论

报告相同问题?