Forum Moderators: coopster
I have a mysql table with a field "AMT" which is int.
Suppose the table contains 3 records i.e
id = 50, Amt, 10
Id = 51, Amt 50
id = 52, Amt 100
Now i want a logic in php which could calculate the AMT of 3 rows. i.e 10+50+100
and then echo the Sum of all AMT.
As the above query fetch all the rows which contains PARENT value.
waiting for reply
You can do that by SQL that is:
SELECT SUM( Amt ) AS AmtTotal FROM sum BIDREQUESTS WHERE PARENT = '$Parent'"
and also there is another way, that is
$sql = " SELECT * FROM BIDREQUESTS WHERE PARENT = '$Parent'";
$sqlres = mysql_query($sql);
while ($row = mysql_fetch_assoc($sqlres)) {
$Total += $row['Amt'];
}
I think by SQL is the best option.
Thanks
Mahabub