我有这段代码:
$result = mysqli_query($conn, "SELECT SUM(angsuran) FROM `laporan` WHERE id_mustahik=".$detail_campaigner->id_mustahik."");
$row = mysqli_fetch_assoc($result);
print_r($row);
当我运行此代码时,结果是:
Array ( [SUM(angsuran)] => 30000 )
但我希望它只显示“30000”数字,而不是“数组([SUM(angsuran)] =>)”。
我该怎么做?
答案 0 :(得分:4)
在您的查询中添加别名,例如
Resource.resx: (used shift+enter to add line break)
LongText:
Long text needed to show/
With to line in the browser
View.cshtml:
(just adds one space -> Long text needed to show/ With to line in the
browser)
@MyResources.Resource.LongText
答案 1 :(得分:-1)
我有两种方式
使用array php
$result = mysqli_query($conn, "SELECT SUM(angsuran) FROM `laporan` WHERE id_mustahik=".$detail_campaigner->id_mustahik."");
$row = mysqli_fetch_assoc($result);
echo $row["SUM(angsuran)"]; // out 30000
修改sql
$result = mysqli_query($conn, "SELECT SUM(angsuran) as sum FROM `laporan` WHERE id_mustahik=".$detail_campaigner->id_mustahik."");
$row = mysqli_fetch_assoc($result);
echo $row["sum"]; // out 30000