使用PDO获取单个数据并存储在变量中

I have this php script to update data. I need to store result from a query using SUM. I have the code below.

$query=$DBcon->prepare("SELECT SUM(fee) FROM users WHERE list_no=:list_no");
$query->bindParam(':list_no', $sp_no);
$query->execute();
$result = $query -> fetch();
echo $result["figure"];

It displays ARRAY...

If your selecting a single column you can do this:

$result = $query->fetch(PDO::FETCH_COLUMN);
echo $result;

The shortest solution is:

echo $query->fetchColumn();

I think changing echo to print_r($result); will give you the answer. You can also try var_dump on each variable to debug the issues