I am adding elements from my SQL query to an associative array and printing them as is shown below;
foreach ($db->query($sql) as $row)
{
?>
<p>
<?php
//Print details of each row
echo "Sale Date: " . $row['saleDate'] . "<br />" .
"Sale Price: " . $row['salePrice'] . "<br />" .
"Buyers Email: " . $row['userEmail'] . "<br />";
?>
</p>
i would like to be able to get the sum of salePrice for elements which match my SQL query. i know i can use the SQL sum command to get the sum of my whole salePrice column in sql, but i would only like to see the sum of the elements which match my query. Is there a simple way to do this?
Thanks.