I have a class, where i have a function with the following query.
public function count_weight() {
$id = $_SESSION['id'];
$query = $this->db->prepare("SELECT sum( weight ) FROM `fish` WHERE `user_id` = '".$_SESSION['id']."'");
try {
$query->execute();
} catch(PDOException $e) {
die($e->getMessage());
}
return $query->fetchAll();
}
I want to echo out this result on my index-page. Right now it looks like this:
$weight = $users->count_weight();
echo $weight;
Which obviously doesn't work, it only prints out "arraykg".
Any suggestions?