Reputation: 103
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...
Upvotes: 0
Views: 63
Reputation: 51
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
Upvotes: 0
Reputation: 21531
If your selecting a single column you can do this:
$result = $query->fetch(PDO::FETCH_COLUMN);
echo $result;
Upvotes: 1