Sorry for asking a simple question.
Im still new to php, so im still learning.
For example using the while($row = mysql_fetch_assoc($sql))
, I queried and echoed a single column name "weight", after 4 results, each $row['weight']
has values of 30,15,20,35. How can I fetch these values and perform addition to get the total value of the weight.
<?php
$sql = mysql_query("SELECT weight FROM table WHERE ID = '$ID'");
while ($row = mysql_fetch_assoc($sql)){
echo $row['weight'];
?>
Sample output:
30
15
20
35
I want to perform ADDITION.
30+15+20+35=100