I am having a problem, which I hope someone could help me with.
I am using CodeIgniter to pull results from a database, and I would like to add these results together. I am not much of a PHP developer, so I am not too sure where to start.
This is the function I am using;
function get_warranty($id) {
$this->db->select('warranty');
$this->db->where('sID', $id);
$query = $this->db->get('cars');
return $query->result();
}
This function, returns this;
[warranty] = Array
(
[0] => stdClass Object
(
[warranty] => 2
)
[1] => stdClass Object
(
[warranty] => 5000
)
)
But, I would like it to return this;
[warranty] = 5002;
So, it simply adds up each result it finds.
Any help at all, would be greatly appreciated, as I say, I'm not much of a PHP developer, so I don't even know where to start.
Thanks in advance!