Anyone knows how to get sum of number?
For example i have mysql column name package.
Package 3 4 1 3 4
If package 3, the value should be usd 5, if package 4, value should be usd 10, if package 1, value should be usd 1 and so on.
So the total value above should be => 5 + 10 + 1 + 5 + 10 = 31
So how do i get sum of it in php?
i tried array_sum .. but it gives me error, im not very expert in php.. Please help me
Thanking in advance.
Get the database to do the work:
The right way of doing it, if you’ve got more than a few values be to modify the table to contain the amount field so you can do:
Alternatively have another table that you contained the relationship between the values (package, amount), and then do
Or, if you really want to do it in PHP: