我是一个爱好开发人员,我遇到了一个障碍,我已经试着解决了几天了,所以我首先要感谢任何能帮助我的人。
我试图通过php显示以下结果。
(nb-历史积分转换为1万美元)
$get_earned = mysqli_query($conn, "SELECT SUM(history_points) FROM activity_history") or die(mysql_error());
while($row = mysqli_fetch_array($get_earned)){
$total_points = $row['SUM(history_points)'];
结果是
SUM ( `history_points`)
218903.0000
然后,我使用以下方式显示此结果:
php echo "$".convert(number_format($total_points));
现在问题是它显示为 $0.0218
什么时候应该读 $21.89
我尝试了下面的方法,它显示$0,其中10000是点到美元的转换。
$get_earned = mysqli_query($conn, "SELECT SUM(history_points * 10000) FROM activity_history") or die(mysql_error());
我完全不知所措。
2条答案
按热度按时间7gs2gvoe1#
试试这个:
cngwdvgl2#
将查询更改为:
列名也会更改,因此必须在php中获取正确的值。
根据@pritaeas的建议,最好使用别名。